writing data to file

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
abcuser
Posts: 13
Joined: 26 March 2008, 20:21 PM

writing data to file

Post by abcuser »

I am collecting a set of data using pulsein(). I am able to get the pulse width but would like to know if I can store it in a text file. I am using the zx-24a. Any help would be appreciated.
dkinzer
Site Admin
Posts: 3120
Joined: 03 September 2005, 13:53 PM
Location: Portland, OR

Re: writing data to file

Post by dkinzer »

abcuser wrote:I [...] would like to know if I can store [output data] in a text file.
There is no simple way to do so but it can be done indirectly. If you are outputting the collected data to Com1 and you are using the IDE, you can select the data that appears in the Debug window using the mouse and then copy it to the clipboard using ctrl-C. Subsequently, you can paste the clipboard data into any application that accepts text and save it. Note that the Debug window only keeps the last 100 lines by default. If you have more data than that you can increase the Debug Output Limit.

The second alternative is to capture the output from Com1 using the ZLoad utility. The most straightforward way to to this is to redirect the output to a file:

Code: Select all

zload -m > data.txt
The disadvantage of this method is that you can't see the data as it is being output. A workaround is to use the undocumented "logging" ability of zload:

Code: Select all

zload -mdata.txt
This command outputs the received data to the named file (data.txt) and also routes it to the console so that you can see it.

A third alternative is to use one of the many terminal programs that supports data logging. I use TeraTerm but there are many of this type of "terminal emulator" program from which to choose.
- Don Kinzer
stevech
Posts: 715
Joined: 22 February 2006, 20:56 PM

Post by stevech »

or with greater difficulty, interface an SD card via SPI. I've downloaded, read about, but not used C code for an AVR that implements Mirosoft's FAT16 file system, as you see on SD cards for digital cameras, mp3 players, etc.
abcuser
Posts: 13
Joined: 26 March 2008, 20:21 PM

Re: writing data to file

Post by abcuser »

" The second alternative is to capture the output from Com1 using the ZLoad utility. The most straightforward way to to this is to redirect the output to a file:

Code: Select all

zload -m > data.txt
"


where would I enter the code 'zload -m > data.txt'. I try to do it in the zload.exe using command prompt while Zbasic ide was open but it gave me the message 'Can't open COM1'.
dkinzer
Site Admin
Posts: 3120
Joined: 03 September 2005, 13:53 PM
Location: Portland, OR

Post by dkinzer »

The application zload.exe is a command line utility; it must be invoked from the command line. If you don't have an icon for "Command Prompt" on your desktop, you should be able to find it on the "Accessories" sub-menu of the "Start->Programs" menu.

In order for this to work, you'll either need to exit the ZBasic IDE application or close the serial port manually. There is an entry on the Options menu for doing so.
- Don Kinzer
liam.zbasic
Posts: 163
Joined: 24 March 2008, 23:33 PM
Location: Southern California (Blue)

Post by liam.zbasic »

Is there a RS232 compliant serial-out command?
dkinzer
Site Admin
Posts: 3120
Joined: 03 September 2005, 13:53 PM
Location: Portland, OR

Post by dkinzer »

liam.zbasic wrote:Is there a RS232 compliant serial-out command?
I'm not sure I understand the meaning of your question. All characters that are added to a queue that is associated with a serial channel as the output queue are transmitted in compliance with RS-232 framing and timing requirements. The signal levels are not RS-232 compliant unless you add the external level converter circuitry. The control flow signals (DTR, DSR, DCD, RTS, CTS) are not implemented nor is the XON-XOFF protocol.

What other aspects of the RS-232 standard are you concerned about?
Last edited by dkinzer on 02 April 2008, 19:55 PM, edited 1 time in total.
- Don Kinzer
abcuser
Posts: 13
Joined: 26 March 2008, 20:21 PM

Post by abcuser »

Got it. Thanks
Post Reply