Subject: Atmel and ZBasic C help wanted.
From: Rotary Engine
Date: 5/17/2010, 9:08 AM
To: AAA Put this in the To box



   I suggest if you are interested in this system you make
   a folder and drag over all the many future messages on this
   subject otherwise delete it.


snips.....................

 -----------------------------------------------------------

 The ZBasic IDE was sending the compression pressure sensor  info
 in limited length ASCII character lines to the PC using the USB
 port.

 That is not what a spread sheet wants or needs to chart.
 So I wrote a short QB program to convert that file to
 a .csv file of a single line up to 32,000 characters long.
 Worked like a charm. I'll give that program to anybody that wants it.

 That file then loaded directly into my Open Office spread sheet
 and this is what the chart looked like.

 Here is the procedure. Cut and past the output data
 into a WordPad text file. Give it a name and save it.
 RUN the QB program and you will get a long.csv file.
 Load that into a spread sheet and chart it.

 Your done. Here is what it looks like.
 Basically this is what the compression sensor output will
 look like.

 This is not scaled data. I did it as test of the A to D.
 I was feeding the 10 bit A to D with a triangular
 wave between zero and five volts using a signal generator.

 Five volts is 1024 from the A to D  so that
 is what you are seeing. In the final version the sensor will
 be calibrated and scaled  in the Atmel program and the output
 will be in psi.

 http://www.zbasic.net/

 So simple a caveman like me can do it.


 Paul Lamar

Paul,
That looks real cool.  Something that you can print and save for future
reference.

I ordered my board and pressure sensor on Friday... should be here this
week.  I would appreciate a copy of your program.  Warning: I may have
questions.  ;-)

Thanks,
Mark
(Pre-caveman)

I had help from Bob. He operated the scope while I was programming.

-----------------------------------------------------------
Here is the QB source code.
Let me know if you need QB. The whole thing (IDE and compiler) is
small enough to email in zip form. Runs in Windows XP in the command mode.

CLS
OPEN "outdat3.csv" FOR INPUT AS 1 '....raw data out of the ZBasic IDE.
OPEN "longdat.csv" FOR OUTPUT AS 2  '..make a new file for a spread sheet.
 FOR x = 1 TO 3000 '....................3000 characters. can be up to
32,000.
char$ = INPUT$(1, 1) '.................get one character at a time
    IF ASC(char$) = 10 THEN GOTO skip 'check for line feed.
    IF ASC(char$) = 13 THEN GOTO skip 'check for carriage return.
 PRINT char$; '.............................print on screen.
long$ = long$ + char$ '................add the character to a long string.
 skip:
NEXT
 PRINT #2, long$ '......................store the long string in a new
file.
END



Paul Lamar

Paul,

Program looks simple enough, but thanks for the notations on each line.
I've downloaded the files from ZBasic.  Are those the same files you're
referring?

Mark

There are two Basics. QB runs in Windows XP. Use it to process data after
it arrives from the Atmel computer. The other Basic is ZBasic. That is stuff
you write to get the Atmel to do your bidding. Stuff like control the EFI
or record the engine compression. BTW there is an apnote on how to control
ultrasonic distance ranging. You might be interested in that.

The communication software that runs in the Atmel and the PC that allows the
two computers to talk to each other is cast in  concrete so one has no control
over that. These programs in general are known as "terminal" programs.
They have been around since the dawn of the computer age.

Unfortunately it does a few things that may not be what one
wants. I would like it to send Atmel data to a HD file in the PC.
Old terminal programs did that no problem. All terminal
programs in digital cameras do that as well. It may be possible
I just have not been able to figure it out yet.

So far I have been cutting and pasting off the screen of the PC
into a Windows NoteBook .csv file. That works but it is a few extra
steps we should not need.

If some of you C gurus would take a look at this program
perhaps there is a way of doing it.
http://www.scintilla.org/
There is stuff in there I have never heard of.

"A lexer for a particular language determines how a specified range of
text shall be colored.  Writing a lexer is relatively straightforward
because the lexer need only color given text.  The harder job of
determining how much text actually needs to be colored is handled by
Scintilla itself, that is, the lexer's caller."

This is total gibberish to me. What the heck is a lexer?
Sounds like one would need a Phd in "C" or computer science.
It is common in computer science to change the definitions
of words. For example "colored" and "color" ?????

Google:
"In computer science, lexical analysis is the process of converting
a sequence of characters into a sequence of tokens. A program or
function which performs lexical analysis is called a lexical analyzer,
lexer<< or scanner. A lexer often exists as a single function which
is called by a parser or another function."

I know how to write those in QB but not C.

I will also send the Atmel basic source code as we go along.

Here is the one for test the A to D function.

-----------------------------------------------
Dim x as Integer
Dim val as Integer

Sub Main()

For x = 1 to 800
'controls the length of time sampling for 8 seconds.

val = GetADC(82)
'get the data

Console.Write(CStr(val) &",")
'send the data out in comma delimited form for spread sheets.

Delay(0.001)
'sample the data 1000 times a second.


next
End Sub
-------------------------------------------

You will need this ASCI chart when writing QB programs
that reformat the data to know how to handle hidden characters like
line feed (lf) and carriage return (cr). They are treated as
just another decimal number in QB. You won't really need to learn
this as I will supply the needed programs in source code or
a simple executable program running in Windows XP command mode.

It would also be possible for someone to write GUI programs in "C" or
VB for running in the Windows  GUI that reformat the data
coming in from the Atmel. Beyond my pay grade at the moment :)

Paul Lamar

-- 
The Rotary Engine NewsLetter. Powered by Linux.
ACRE NL web site. http://www.rotaryeng.net
Youtube key word PaulLamar2
Copyright 1998-2010 All world wide rights reserved.