Newbie question, about recieving a number and send it to a DAC
avionikeren
Posts: 64
I can send a number to the DAC and the output of the DAC changes... number 0 = 0 volt and number 255 = 5 volt
but when I try to send a number recieved with rs232 the output will not respond, here is some of the code:
but when I try to send a number recieved with rs232 the output will not respond, here is some of the code:
VARIABLE := serial.Rxdectime(1) outa[noparse][[/noparse]daccs] := 0 BS2.SHIFTOUT(dacdata,dacclk,loaddacb,BS2#MSBFIRST,8) BS2.SHIFTOUT(dacdata,dacclk,VARIABLE,BS2#MSBFIRST,8) outa[noparse][[/noparse]daccs] := 1
Comments
You need to provide more information like what kind of DAC you are using, and how you have it hooked up to the Propeller. Also the pin numbers that you are assigning to dacdata,dacclk,loaddacb.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Beau Schwabe
IC Layout Engineer
Parallax, Inc.
It`s when I use a variable, it stops working:
Being completely obvious, it's not this is it?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"VOOM"?!? Mate, this bird wouldn't "voom" if you put four million volts through it! 'E's bleedin' demised!
In your code you wait for one ms for a value. That might be to short if you enter it manually with a terminal-program.
And rxdec/rxdectime need a string delimiter which usually is the carriage return (=13). The delimiter is needed to find the end of the number. 1 is a one digit number, 10 is a two digit number but for the program there is no difference in the 1 in the 1 digit number and the 1 in the 2 digit number, so how should it know how many digits it should expect? That's why you have to send an end of number character. You can set it with SetDelimiter(char) to any other character.
If rxdectime does not receive a number·AND it's delimiter within one millisecond, it will· ... hmmm .... return -1 or abort. I'm not sure·with this - never used the abort in my code so far.·For me it looks like the abort is unreachable code because the return comes first?! If you don't catch·an abort condition, your program will end.
If abort is not reached you very likely get a -1 as value which translates to a byte as %11111111.
Post Edited (MagIO2) : 5/29/2009 9:43:57 AM GMT
you might want to try something like this
( code is untested, but you should get the idea from the source )
basically only set VARIABLE when you get a valid value from serial
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
http://www.propgfx.co.uk/forum/·home of the PropGFX Lite
·
I sent this to the prop: s,101,102,103,104,105,106,107,108,109,
And this is what it understood at 115200: s,101,102,103,108,109,255,255,255,255