Potential New ZBasic User

Discussion about the ZBasic language including the System Library. If you're not sure where to post your message, do it here. However, do not make test posts here; that's the purpose of the Sandbox.
Post Reply
liam.zbasic
Posts: 163
Joined: 24 March 2008, 23:33 PM
Location: Southern California (Blue)

Potential New ZBasic User

Post by liam.zbasic »

Hello,

I started with Parallax a few years ago, then I moved up to Picaxe, and now I'm ready to move on. I'm looking for 32bit floating point math capability in a Basic language environment. The PIC chips are unfortunately limited with floating point math, and I just don't trust BasicX, they fail to answer simple questions.

I'm very impressed with the ZBasic website and documentation and ready to purchase the ZX-40n. I'm new to AVR chips so I have a few questions... is the floating point math a software (as in PIC) or hardware feature? I there a simple document showing how to program a simple "hello" program, compile, and download to the chip? Appreciate your help. Thanks.

Liam
GTBecker
Posts: 616
Joined: 17 January 2006, 19:59 PM
Location: Cape Coral

Potential New ZBasic User

Post by GTBecker »

> ... BasicX, they fail to answer simple questions...

Please. You never spoke with anyone associated with BasicX beyond being
longtime users; we are volunteers, friend, there, and here, to help
folks like you. Your difficulty is that you choose to ask us rather
than read the documentation to answer your "simple" questions - even
after I answered the first one, and steered you with a link to the
other answers. Read, man.


Tom
Tom
liam.zbasic
Posts: 163
Joined: 24 March 2008, 23:33 PM
Location: Southern California (Blue)

Post by liam.zbasic »

"BasicX" is the company, it's employees, their website and their forum. BasicX's sanctioned forum on yahoo was unable to answer simple questions, except for smug responses questioning my literacy. To me, a vendor's documentation and forum is a criteria for my purchase. I have read through a myriad of ZBasic's documenation in my spare time. MCUs are fascinating and I enjoy creating simple projects. But I am still new to microcontrollers, I don't have an electrical background, so I don't wholly understand it all. I have to rely on forums to get unstuck. I'm sorry if my questions bother you Tom, just ignore them. I can't stop asking questions because it bothers people. Forums are part of the learning process too, and I will use it as such. Thanks.

Liam
stevech
Posts: 715
Joined: 22 February 2006, 20:56 PM

Post by stevech »

In general, I believe that ZBasic is a superset of BasicX, though I never used BasicX.

In this document
http://www.zbasic.net/doc/ZBasicRef.html
section 2.2, page 5, you'll see that floating point data types are supported.
and in
http://www.zbasic.net/doc/ZBasicSysLib.html
page 66 on csng() discusses float to long

I don't think ZBasic supports the double type, 64 bits. It's kind of burdensome for an 8 bit micro.

There is a floating point co-processor chip (3rd party) you may use if you are calculating the meaning of life or the angle between the earth and our nearest star 100 times a second.

s/non-employee of Elba Corp.
dkinzer
Site Admin
Posts: 3120
Joined: 03 September 2005, 13:53 PM
Location: Portland, OR

Re: Potential New ZBasic User

Post by dkinzer »

liam.zbasic wrote:s the floating point math a software (as in PIC) or hardware feature?
The floating point math is implemented in software. There are few, if any, microcontrollers that have a hardware floating point unit.
liam.zbasic wrote:Is there a simple document showing how to program a simple "hello" program, compile, and download to the chip?
At present, there is no step-by-step tutorial. That said, getting started is pretty simple. Here is an elementary "Hello, world" program in ZBasic:

Code: Select all

Sub Main()
  Debug.Print "Hello, world!"
End Sub
In order to compile this program and download it to your device follow the steps below. The description assumes that you have a ZX properly connected on a prototyping board of some type, that a serial connector is properly wired and that it is connected to a PC's COM1 port by a serial cable.
  • Launch the ZBasic IDE.
  • Select "New..." from the Project menu
  • In the edit box of the New Project dialog, type the name of the project, for example, hello.pjt. You may want to change the directory where the project file will be located by using the Browse... button on that dialog. Leave the checkboxes checked and click the OK button when ready to proceed.
  • Note that the main source code file, hello.bas for example, is automatically created and an empty Main() subroutine is prepared in that file. Add a new second line containing the Debug.Print command from the example above.
  • From the Options menu, select "Device Options..." and in the resulting dialog, select the device name corresponding to the ZX device that you have, e.g. ZX-24a. Click the OK button when ready to proceed.
  • If the ZX is connected to a COM port on the PC other than COM1, you'll need to select the right COM port. Do this by selecting "Serial Port Options..." from the Options menu and then choosing the right COM port from the dropdown box labeled "Serial Port". Press OK when ready to continue.
  • Compile your program by pressing the F7 key or by selecting Compile from the Project menu. In the Output window at the bottom of the IDE, you should see that the compile completed with no errors. If an error message appears, recheck the program to verify that it matches the sample above and compile it again.
  • Download the compiled program the the ZX by pressing the F5 key or by selecting Go from the Project menu. If the download completes successfully, you should see the "Hello, world!" in the Debug window at the bottom of the IDE.
If you are not well skilled in breadboarding circuits, I highly suggest that you begin with one of the 24-pin ZX devices instead of the 40-pin devices. The 24-pin devices are more ready-to-use, requiring only a power supply and a serial port connection. The 40-pin devices require some additional external circuitry and are recommended for advanced users. Less experienced users may also be well advised to choose a VM mode device like the ZX-24 and ZX-24a instead of a native mode device like the ZX-24n.
- Don Kinzer
liam.zbasic
Posts: 163
Joined: 24 March 2008, 23:33 PM
Location: Southern California (Blue)

Post by liam.zbasic »

dkinzer,

Thanks very much for your response. I learned to breadboard with the parallax stamp and picaxe. I've been examining the ZX-40 for purchase, but not sure whether to do the 40a or 40n. I'm steering away from 40a because the "advanced floating point" functions are "system level". I interpreted that to mean software floating point as opposed to hardware, but now I realize that's incorrect based on your info. I've been leaning toward the 40n due to its superior speed and non "system level" floating point, but I admit I don't wholly understand the meaning of "runs native code for the processor". The 40a and 40n are identically priced, the latter is faster, so would the 40n be appropriate for a post-parallax, post-picaxe user? I appreciate your comments.
pjc30943
Posts: 220
Joined: 01 December 2005, 18:45 PM

Post by pjc30943 »

Post-parallax, you'll find any of the ZX devices far superior:)

[The rest removed, since Don replied with more detail]
Last edited by pjc30943 on 25 March 2008, 17:01 PM, edited 1 time in total.
dkinzer
Site Admin
Posts: 3120
Joined: 03 September 2005, 13:53 PM
Location: Portland, OR

Post by dkinzer »

liam.zbasic wrote:I'm steering away from 40a because the "advanced floating point" functions are "system level".
The notation "system level", which is applied to advanced floating point functions like sin, cos, tan, etc., is intended to indicate that those functions are implemented in system code. This is in direct contrast to BasicX where the advanced math functions are implemented in user code which implies both that they take up user code space and that they run more slowly. All floating point operations in all ZX devices, whether VM or native mode, are implemented identically.
liam.zbasic wrote:I don't wholly understand the meaning of "runs native code for the processor".
Many (perhaps most) Basic-programmable microcontrollers implement the "virtual machine" model. For this model, the compiler translates your program to a series of special instructions, often called "pcode". When the program is downloaded, a special program on the microcontroller, called an interpreter or virtual machine, reads each instruction code and performs the corresponding action. Although this method results in slower execution, it has several advantages including generally smaller code size and a more controlled execution environment. The BasicStamp, BasicX, PIC-Axe and most ZX devices use the VM model.

With native mode devices, the compiler translates your program into instructions that are directly executed by the microcontroller. Because the "middle man" interpreter has been eliminated, the program runs substantially faster. The disadvantages of native mode devices are that a given program generally compiles to a larger downloadable size and there are potentially more details for you, the programmer, to handle that are typically taken care of by the virtual machine. That's why we recommend the native mode devices for advanced programmers.

If cost is a significant element of your decision-making process, don't forget that you need to buy additional components for the 40-pin ZX devices before they'll do anything useful.
- Don Kinzer
liam.zbasic
Posts: 163
Joined: 24 March 2008, 23:33 PM
Location: Southern California (Blue)

Post by liam.zbasic »

dkinzer,

Your response clarifies many questions. I'll be sure to get the "zx parts kit". Your info should get me started. Thank you very much.

Liam
spamiam
Posts: 739
Joined: 13 November 2005, 6:39 AM

Post by spamiam »

Do take Don Kinzer's advice and use the regular ZX-24 before going to the ZX-24n. The native mode weill ruin faster, but there is more complexity getting to the point of running the program.

On the regular ZX-24, using the virtual machine, it is a piece of cake going from writing, to downloading, to running. The development cycle is fast and easy.

If you need more I/O pins then there are other options available (in the greater ZX family) without having to hook up all the supporting hardware (a la ZX-40) yourself. While I have some of the larger devices, 99% of what I am doing can be done with the 24 pin device.

-Tony
P.S. You will never find better support than what you get here from Don (who designed, built the ZX and wrote the entire interpreter and compiler), and the other experts. I have been such a beneficiary of their expertise many times.
-T
liam.zbasic
Posts: 163
Joined: 24 March 2008, 23:33 PM
Location: Southern California (Blue)

Post by liam.zbasic »

My package of chips and "parts kit" arrived. Very excited. The ZX-40a schematic (suggested serial interface #1) calls out several 6.8K resistors - same with the ZX-40a chip. However, the "ZX parts kit" only has 10K resistors. Is this okay? Also, the packaging elaborately protects all parts from ESD. Is this really a concern now that the parts safely arrived? Thanks.
dkinzer
Site Admin
Posts: 3120
Joined: 03 September 2005, 13:53 PM
Location: Portland, OR

Post by dkinzer »

liam.zbasic wrote:However, the "ZX parts kit" only has 10K resistors.
The value is not critical. Although the ZX-24 and ZX-24a originally used 6.8K resistors, the current production uses 10K. The higher value reduces power consumption slightly.
liam.zbasic wrote:Is [ESD] really a concern now that the parts safely arrived?
ESD damage is always a potential problem. The likelihood of damage depends on the environmental conditions. Generally speaking, you should be OK if you always touch something that is grounded (e.g. a metal computer case) first before touching any parts.

You can find more information on ESD damage prevention online.
- Don Kinzer
liam.zbasic
Posts: 163
Joined: 24 March 2008, 23:33 PM
Location: Southern California (Blue)

Post by liam.zbasic »

My ZX-40a is working (after fixing a few misplaced wires). Your quickstart instructions were very helpful.

I noticed that the "suggested serial interface #1" and the transistor's collector is probably missing a 10K resistor to +5V. Is this correct or is the 10K resistor just an extra? My ZX-40a is working fine with this setup.

I've fiddled with the "hello world" program, added subroutines, add floating point equations, and absolutely impressed that Elba corp. was able to implement visual basic with floating point capability. I can not see ever using my one basic stamp and pbasic ever again (and too expensive). Although I'll always have a special place for picaxe chips (great forum).

Thank you for your great product.
dkinzer
Site Admin
Posts: 3120
Joined: 03 September 2005, 13:53 PM
Location: Portland, OR

Post by dkinzer »

liam.zbasic wrote:I noticed that the "suggested serial interface #1" and the transistor's collector is probably missing a 10K resistor to +5V.
The circuit diagram in the manual has two resistors in the upper left corner. The leftmost of those is connected to the collector of the transistor and the RST/ input of the processor.
- Don Kinzer
Post Reply