SEROUT and 12Bit ADC
sumguy16
Posts: 21
I am working on a wireless ADC. I have completed the prototype using a BS2, now for the hard part: switching to the SX20. I've just started working the SEROUT command with SX/B and have succesfully sent data across a wireless network. I cannot however transmit variables, I can only transmit constants. Here is my code:
I don't understand why this doesn't work, when I use hyper terminal I get a bunch of garbage, and when I change i to a constant the value is transmitted?
Also, I'm using a 12bit ADC and I would like to possibly use a 16bit ADC, any advice as to transmitting a 12bit value when I'm dealing with an 8bit byte?
And lastly, is it possible to transmit at 19200Bps @ 4MHz? Right now I'm running at 50MHz which isn't necessary and is a waste of power.
Thanks for reading!
Adam
i var byte TX_Byte sub 1 Start: pause 200 for i = 0 to 20 TX_Byte i pause 20 next goto Start TX_Byte: SEROUT ra.0, T19200, __PARAM1 return
I don't understand why this doesn't work, when I use hyper terminal I get a bunch of garbage, and when I change i to a constant the value is transmitted?
Also, I'm using a 12bit ADC and I would like to possibly use a 16bit ADC, any advice as to transmitting a 12bit value when I'm dealing with an 8bit byte?
And lastly, is it possible to transmit at 19200Bps @ 4MHz? Right now I'm running at 50MHz which isn't necessary and is a waste of power.
Thanks for reading!
Adam
Comments
' Use: TXBYTE theByte {, repeats }
' -- first parameter is byte to transmit
' -- second (optional) parameter is number of times to send
TXBYTE:
· temp1 = __PARAM1············ ·' char to send
· IF __PARAMCNT = 1 THEN······ ·' if no repeats specified
··· temp2 = 1·················· ' - set to 1
· ELSE
··· temp2 = __PARAM2
· ENDIF
· DO WHILE temp2 > 0
··· SEROUT Sout, Baud, temp1··· ' send the character
··· DEC temp2
· LOOP
· RETURN
Another thought -- you should send printable ASCII characters to Hyperterminal; use "A" TO "Z" in your loop instead of 0 TO 20.· You should be able to do 19.2K with a 4 MHz resonator (note, you cannot do serial with the internal oscillator), but I'd probably bump to 8 MHz to be safe.· Once you get the basic serial stuff going (should be easy, I do it all the time and have no problems with HyperTerminal) then you can transmit like you do with your BASIC Stamp: one byte at a time.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Post Edited (Jon Williams (Parallax)) : 10/25/2005 12:31:02 PM GMT
I would be grateful if someone could point me in the right direction, this is my first major project that I have done on the SX. Trying to make the jump to where the professionals play...
Thanks,
Adam
If you'll tell me specifically what ADC you're using I'll write a demo for you.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Post Edited (Jon Williams (Parallax)) : 10/27/2005 3:33:44 AM GMT
Adam
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Thanks again Jon,
Adam
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
The output with the bread board version is something like: V0FFF%0000
Where the first character determines the measurement type, next the value of the meaurement on ch1 seperated by a % sign and then the last value of ch2 is displayed. With the proto board version I get: V‚‚‚* with two blocks after the asterisk. I have read things about bit shifting, but I am not sure why this would come up from transferring from a bread board to a pc board.
I thought that this process would be a matter of switching pin assignments in the code, but I guess not...
Any ideas would be greatly appreciated,
Adam from Seattle
On your proto board, what are you using for a clock for the SX? A resonator, a TTL clock, or the internal 4 MHz clock?
Thanks, PeterM
I also find that the SX is really sensitve to the lead length between the SX and the clock source.· Now when I do a PC layout, the first thing that goes on, and as close to the SX as I can get it, is the clock source.
Nate