Using the serial port

so for a project i am currently working on, i need to give input to the serial port on the bot board 2.
based on the input i need to do different things. seams simple but for some reason my code wont work.

enablehservo
enablehserial
hservo [p0\0\255,p1\0\55]
inputData var byte
inputData=0
 
main
 
hserin [inputData]
hserout [dec a]
 
#if inputData=0
 ;stop
 hservo [p0\0\255,p1\0\255]
;#else
; #if inputData=1
;  ;forward
;  hservo [p0\12000/255]
; #endif
#endif
 
goto main

so the idea is that i am going send data like forward, stop, back, turn and it should move
this complies but doesn’t seam to work

Thank you in advance for your help

Looks like you might need to initialize the serial port:

ENABLEHSERIAL ; needed in PRO
sethserial H38400, h8databits, hnoparity, h1stopbits; works

Alan KM6VV

I have the enablehserial
whats the other line?
whats that do

sethserial H38400, h8databits, hnoparity, h1stopbits

You need to set the baudrate for the ‘H’ serial (hardware) interface. P14 & P15, TTL.

Did you perhaps mean to use the BM built-in RS-232 level converter?

Alan KM6VV

yes sorry it is the built in one

Then for AtomBasic,

You’ll want something similar to these statements:

serout S_OUT, i38400, “Creepy”,cr]

serin S_OUT,i38400,200000,NoData,[var]

Slightly different for the 'pro.

Do the “COM” builds using PowerPod for either AtomBasic or 'pro, and you’ll get code that will drive your com port.

Alan KM6VV

whats the code for the pro?

whats powerpod?

can anybody help?

Sorry, probably out eating turkey!

Powerpod is a program you can download from lynxmotion:
lynxmotion.com/Product.aspx? … egoryID=15

Code looks pretty much the same for Basic Atom Pro…

looks cool!
thanks guys!!
ill be working on it this weekend, ill let you guys know how it goes

I would really appreciate it if someone could help me here, im completly lost.

Powerpod wants a master program, a pmp file, it also sais its for the ssc-32.

can someone write me the very basic source for the pro. Just the actually I/O stuff, I need an example for this. I would really appreciate it.

Thank you!

Just use PowerPod to generate a 'pro program for you, one that uses com to control it. Then study the code generated, you’ll see the serin and serout code in use.

the code below cycles an LED


serout S_OUT, i9600, "Flash LED"]	; 

LED_D2 		con P2		; LED C

loop
low LED_D2	; LED C "heart beat" ON
pause 500	; mS
high LED_D2 ; LED C "heart beat" OFF
goto loop

Alan KM6VV

ok so i still cant get this working…

heres my code

[code]enablehservo
hservo [p0\0\255,p1\0\55]
inputData var byte
out var byte
inputData=0
out=0

main

serin S_OUT,i9600,[inputData]

#if inputData=dec 2
;stop
;out=5
;serout S_OUT,i9600,[13, dec out]
hservo [p0\0\255,p1\0\255]
#else
#if inputData=dec 3
;forward
out=6
serout S_OUT,i9600,[13, dec out]
hservo [p0\12000\255]
#endif
#endif

inputData=0

goto main[/code]

any ideas??

I’m jumping in the middle here, but try figuring the serial inputs to do something simpler like turn on an LED. Then we can work on the servo stuff. It might be easier to use pulsouts. For the Bot Board II with Atom Pro to turn on and off the LEDs do this.

low 12 'turn red LED A on input 12 'turn red LED A off low 13 'turn green LED B on input 13 'turn green LED B off low 14 'turn yellow LED C on input 14 'turn yellow LED C off

Hope this helps!

the servo stuff is not the problem right now, its the communication through the built in serial port in the BBII.

You are going to have to provide a lot more information. What is sending the data? Can you provide code examples?

Did you try what I suggested? What results?

Break the problem up. First get an echo of what you’re sending back to your terminal emulator program. the ‘2’ you’re looking for can be confusing; are you sending an ASCII character ‘2’? or binary value 02H?

After you get an echo back and see what you’re receiving (buad rate conflicts?), then you can expand the program and get the conditional working, and turn on/off some LEDs

Once you get the LEDs to respond properly, then work on sending servo commands out.
Alan KM6VV

I have not used powerpod because it does not seam to be what im looking for.

for now I am sending the data with a serial port terminal written in C#. this is the link for that if anyone is interested: msmvps.com/blogs/coad/archive/2005/03/23/39466.aspx

The eventual goal is that I will have a python program send the data but I will Wright this once i get the basic code done. I am sending an ASCII character not a hex value.

when i was trying this earlier, i keep getting “5” as a response, even with the serout commented, it will still sending a 5, what does that mean, what is this number.

Your C# terminal program is probably holding the AtomPro module in reset. The RTS(or DTR) pins are connected to the reset pin of the module when in the bot board. Most terminal progr4am will hold these pins in the wrong state(they need to be cleared). Also you should use no flow control in your terminal comport settings. For testing purposes you should be using the builtin terminal windows in Basic Micro Studio. Those already set the RTS and DTR pins correctly when connecting.

tried with the buit in terminal and got the same result, as soon as i hit enter, its displays a 5 in the next line so im not sure if it is sending 2 of 52?