NEWBIE - help with FULLDUPLEXSERIAL.SPIN & USB2SER Adaptor
DavidM
Posts: 626
Hi,
I wish to communicate with the PROPELLOR vis SERIAL RS232.
I have the DEVELOPMENT BOARD and the USB2SER adaptor.
Q1) How do I wire up the USB2SER to the Prop.
I believe I need to wire up the USB 2SER as follows, but correct me if I am wrong.
VSS on USB2SER -->VSS on PROP ( next to pin 7 )
RX on USB2SER -->Pin 7 on the Prop
TX on USB2SER -->Pin 6 on the Prop
Q2) I firstly want to send some simple commands from a TERMINAL APPLICATION , using the number 1-8 and then when the prop receives them, the LED's 16 to 23 will flash for a second accordingly
eg
Send "1", LED 16 will flash for a second.
Send '2", LED 17 will flash for a second.
and so on..
I have written some code already, I have installed the FULLDUPLEXSERIAL.SPIN code and I am using that in my code. But I am confused on how to use the commands from that code, Are there any examples, or instructions for the fullduplexserial.spin code?
If I send the number "1" via the Serial terminal application to the PROP, then that is ASCII char(31), I believe, so if I have a case statement with each of the characters 31 to 38 then I should be able to flash an appropriate LED ( i.e 16-23)
here is my code I am using..
'' DAVES SERIAL TESTER
VAR
byte vData
CON
_CLKMODE =XTAL1 +PLL16X
_XINFREQ =5_000_000
rxpin =7
txpin =6
mode =0
baudrate =9600
PUB InitOutputLEDs
dira[noparse][[/noparse]16..23]~~ ''Sets all pins from 8 to 23 to outputs
outa[noparse][[/noparse]16..23]~ ''turn off all leds
OBJ
FullDuplexSerial : "FullDuplexSerial"
PUB StartSerialTester
FullDuplexSerial.Start(rxpin, txpin, mode, baudrate)
REPEAT
vData:= FullDuplexSerial.rx
CASE vData
$31 : outa[noparse][[/noparse]16]~~
$32 : outa[noparse][[/noparse]17]~~
$33 : outa[noparse][[/noparse]18]~~
$34 : outa[noparse][[/noparse]19]~~
$35 : outa[noparse][[/noparse]20]~~
$36 : outa[noparse][[/noparse]21]~~
$37 : outa[noparse][[/noparse]22]~~
$38 : outa[noparse][[/noparse]23]~~
waitcnt(20_000_000+CNT)
outa[noparse][[/noparse]16..23]~
The above code does not work!, What am I doing wrong? My RX light on the USB2SER is FLASHING, but nothing on the PROP Board is?
Thanks
Dave Metus
I wish to communicate with the PROPELLOR vis SERIAL RS232.
I have the DEVELOPMENT BOARD and the USB2SER adaptor.
Q1) How do I wire up the USB2SER to the Prop.
I believe I need to wire up the USB 2SER as follows, but correct me if I am wrong.
VSS on USB2SER -->VSS on PROP ( next to pin 7 )
RX on USB2SER -->Pin 7 on the Prop
TX on USB2SER -->Pin 6 on the Prop
Q2) I firstly want to send some simple commands from a TERMINAL APPLICATION , using the number 1-8 and then when the prop receives them, the LED's 16 to 23 will flash for a second accordingly
eg
Send "1", LED 16 will flash for a second.
Send '2", LED 17 will flash for a second.
and so on..
I have written some code already, I have installed the FULLDUPLEXSERIAL.SPIN code and I am using that in my code. But I am confused on how to use the commands from that code, Are there any examples, or instructions for the fullduplexserial.spin code?
If I send the number "1" via the Serial terminal application to the PROP, then that is ASCII char(31), I believe, so if I have a case statement with each of the characters 31 to 38 then I should be able to flash an appropriate LED ( i.e 16-23)
here is my code I am using..
'' DAVES SERIAL TESTER
VAR
byte vData
CON
_CLKMODE =XTAL1 +PLL16X
_XINFREQ =5_000_000
rxpin =7
txpin =6
mode =0
baudrate =9600
PUB InitOutputLEDs
dira[noparse][[/noparse]16..23]~~ ''Sets all pins from 8 to 23 to outputs
outa[noparse][[/noparse]16..23]~ ''turn off all leds
OBJ
FullDuplexSerial : "FullDuplexSerial"
PUB StartSerialTester
FullDuplexSerial.Start(rxpin, txpin, mode, baudrate)
REPEAT
vData:= FullDuplexSerial.rx
CASE vData
$31 : outa[noparse][[/noparse]16]~~
$32 : outa[noparse][[/noparse]17]~~
$33 : outa[noparse][[/noparse]18]~~
$34 : outa[noparse][[/noparse]19]~~
$35 : outa[noparse][[/noparse]20]~~
$36 : outa[noparse][[/noparse]21]~~
$37 : outa[noparse][[/noparse]22]~~
$38 : outa[noparse][[/noparse]23]~~
waitcnt(20_000_000+CNT)
outa[noparse][[/noparse]16..23]~
The above code does not work!, What am I doing wrong? My RX light on the USB2SER is FLASHING, but nothing on the PROP Board is?
Thanks
Dave Metus
Comments
rxpin =6
txpin =7
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
John R.
Click here to see my Nomad Build Log
I have fixed up my PUB code, you are right it will just sit there, I have now revered my rx & tx pin assignment as well.
Am I using the case statement correctly? And am I getting the bytes from the receive command correctly?
regards
Dave M
After you receive data, send it back to the computer:
FullDuplexSerial.tx(vDat)
When you post code, use the CODE button on the editor to start and end a block of code, it helps to see your indentations.
-Maritn
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
StampPlot - GUI and Plotting, and XBee Wireless Adapters
Southern Illinois University Carbondale, Electronic Systems Technologies
I might try that TV stuff you mentioned, I am a programmer already ( 4D database for 3 years) so I now how to write code, without a debugger, its difficult, but your suggestion is a great idea.
By the way I DID GET MY CODE to WORK! yippee!
I had to pay close attention to the INDENTATION from the REPEAT statement, and the very fussy ( and unusual to me) nature of the syntax that spin uses.
Thanks to the other as well.
I feel I have accomplished something!
regards
Dave Metus
Dave as promised some stuff that we spoke about today.
The ADC0831 spin file was an example we did for a customer that was using a Basic Stamp1
sampling an 8 bit a/d converter chip... hacked some code that looked similar .. not the most
elegant way but it shows you the principle of clocking .. looking at data .. addding data as you loop
and finally outputting the data to PINS and doing a compare ....
This was done ages ago...
More stuff attached as well .. though tI share it with all ..
Ronald Nollet···· Australia