SERIN trouble

Hi Everybody.
I’m trying to use the SERIN command but so far, I got nothing. I’m using an ABB-II and an ATOM PRO 28. I’ve hooked my HAC-UM96 wireless modem from sparkfun to I/O pins 14 and 15. I’ve got one modem connected to one of the ABB’s and another modem connected to another ABB. Both of the modems have power, and using the serout command and a volt meter I think I get a transmission from the transmitting modem (I get fluctuations in the voltage of the TxD pin).
For the receiving modem, I wrote the line:
serin p14,N9600, 1000, main,[dec rec]

where p14 is connected to the RxD pin on the modem, main is a sub routine I want the program to go to after 1 second, and rec is the variable which is supposed to receive the transmitted byte.

HOWEVER, the program starts running, but gets stuck on the serin line. It doesn’t jump to MAIN and doesn’t receive any transmission.

Anybody has any idea as to why it doesn’t work? :frowning:

Hi Eran,

I’m also working on the serial input for over a couple of days. See thread: lynxmotion.net/viewtopic.php?t=3820

But I’m able to send single data to the serial input. What you need to try is remove the timeout. And I’m using the bauterate I9600. So I suggest you try something like this:

serin p14,I9600 [dec rec]

There is another tread telling that there are/where some bugs in the compiler which cause the serin timeout to fail. I’m using the last version of the ATOM pro IDE but wasn’t able to get the timeout to work for myself.
lynxmotion.net/viewtopic.php … in&start=0

I hope this helps

Xan

Hi Xan.
Tried that. Unfortunately it doesn’t work.
I upgraded to the IDE ver. 8.0.1.0 and still nothing.
Tried with and without the timeout and still I get the same thing. whenever the program gets to the serin line in debug mode, It gets stuck there. WWWHHHHHYYYY???

Hi eran,

I also find it hard to debug the serin. If the ATOM hits the serin command it looks like it is just waiting for a input and will stop all other processes including your debugging connection. I wish that the ATOM was multithreaded like my pc! :wink:

The way that i debug the serin command is using the sound command to see if i received data. And sending the received data back to my pc using the serout command. 8)

Are you able to send data to your pc using serout?

Xan

I am sending data between two ABB-II, not the PC. Serout works fine. Only serin gives me trouble. I’m trying to switch to the serial port now and use hserin to see if that works

Actually the HSERIAL port uses P14(RXD) and P15(TXD), so I don’t think you will have to change your hardware to try it…

Like Xan, I have found using some of the debug support does not always work well when you are debugging things like Serin, or code with interrupts, etc. I also use Sound commands, serout S_OUT and the LEDS on the BB2 to give me indication of status.

Kurt

So, what’s the difference between pins 14,15 and 1 to 13?

On the Atom Pro (as well as many other processors), there are several IO pins 0-19 that can be used both as a general purpose IO pin or for a secondary purpose. For example pins 0-3 and 16-19 can be used for Analog to Digital input. Some of the pins can be used to receive external interrupts (WKP0-5 and pins 0-5) as well as p8 are IRQ1, p18=IRQ2, P19=IRQ3). I2C on pins P6 and P7.

So on the Atom Pro the hardware serial port is on pins P14 and P15. The 9 pin serial cable is not connected to these pins. It is also simply a another IO pin that is duplexed to both receive and transmit…

Most of these details are found on page 187 of the Atom Pro manual.

Kurt

Let’s say I’m using SERIN. As I understand it, if I write the line:

hserin [dec in_var]

the atom will wait until something is picked up by the modem. I can choose whenever I want to send the data via another ABB and another modem, and the first modem is supposed to “pick” the data from the air.
Am I correct?

I think others are better at answering information about getting the data from the air…

The nice thing about using the hardware support is that you don’t have to be sitting there waiting for the input. So your program can be doing whatever you want it do something and whenever you want you can simply check to see if there is input is available and processing it when you want. Versus software SERIN. If your program is not waiting for input and the characters are transmitted, the input is lost.

Hi all,

Steve Norris at Norris Labs has successfully interfaced a Parallax 912MHz transreceiver with a Basic Atom Pro 28 using the hserin command as follows:

Define pins:

’ RF 912 MHz Transceiver
Pin_RfIn CON 14
Pin_RfOut CON 15

Enable the hardware serial port:

            ENABLEHSERIAL
SETHSERIAL h9600,h8databits,hnoparity,h1stopbits

Receive data:

            ' Check RF receive
DataIn = 0
hserin 1, NoCmd, [DataIn]

            ' Process command
if DataIn = "!" then
           ' Get rest of command
           hserin 100, NoCmd, [str CmdIn\15\13]

Time out code:

NoCmd
’ Execute the Navigate behavior every 10th time
if NavCount = 10 then
gosub Navigate
NavCount = 0
endif

Hopefully this code will give you an idea of a successful receive data flow for an Atom Pro 28.

Just a thought.

Regards,
TCIII

Great news (for me at least).
Using some of your advice and a scope i managed to borrow, I finally figured it out and am now the (very) proud owner of a wireless connection.

You wouldn’t believe the number of mistakes I had. connecting the wrong pins to the wrong ports, sending the wrong info in the wrong encoding…

Now I’m trying something new and I need help again. I want to connect the HAC-UM96 modem to a PC serial port.
Does anyone know how to do that? Do I need anything in between or should I just connect the RX and the TX of the modem to those of the PC??? :slight_smile: