The above is a snippet for the powerpod generated program. The bot is set to be controlled by the serial port, so the main loop
starts out by polling the the serial port of the BB2 and the basic atom pro 28.
From what I can see, the basic program sends the word “Rd” to the serial port to inform the PC program that it is ready to accept commands.
this is done by the command: **serout S_OUT,i9600,“Rd”] ; ‘Ready’ to recieve data now
**
Then the next command : serin S_OUT,i9600,100,NoData,[str DualShock(0)\7] is the actuall serial input command that accepts the input fro the PC program.
The question is how come the same pin (S_OUT) is use as output and as input ?
What I’m trying to do is connect a bluesmirf bluetooth dongle to the BB2+atom pro 28 so the bot can be serially controlled from the PC using a bluetooth connection.
Has anyone done this or has any ideas as to how it can be done ?
if you were to pull a schematic for the BA / BAP modules from the basic micro website you will see the s_out / s_in pin is a half duplex connection. there is some circuitry that does the rs-232 level shift on the module. also note that to program a BA / BAP you need the DTR pin on the serial interface as it is used to reset the module.
From my poor knowledge in programming the BAP, I would presume that the serin command would use the S_IN pin and the serout command would you the S_OUT pin. Why is serin and serout using only the S_OUT pin ?
Also do you have any knowledge about connecting the bluesmirf bluetooth module so as to be able to control the bot with bluetooth. I do not want to program the bot with bluetooth, I only want to control it via the serial interface using the PC program that comes with powerpod.
The first part of your question is that it is probably sort-of a bug, but probably does not hurt anything. Both S_IN and S_OUT map to the same IO pin (14) on the underlying H8 processor and then the hardware that Eddie mentioned takes care of the rest…
As for Bluetooth modules, You should be able to plug the unit into 1 or 2 IO pins on the BB2 depending on if you need bidirectional communications or not. You would then change the code you mentioned to do the Serin from the pin that is connected to the TX pin of your BT and do Serouts to the IO pin that is connected to the RX pin of the BT. You may also need to update the baud rate and other communication parameters to match your BT.
Alternatively Programming wise if you can plug the BT into the IO pins 14 and 15 on the BAP, you could convert the serin/serout commands into the hardware versions hserin, hserout, which gives you the added advantage of hardware buffering. This would require a few modifications to the code such as initializing the hardware serial port, but that is very straight forward.
Obviously on your pc, you would need to have your control program or terminal talk to the appropriate serial port that cooresponds to the BT link.