Strange behaviour of Serin. PC <-USB-> BB2 issue?

Hi guys,

I am using the BB2 with Basic Atom Pro 28.
On the PC side a Vaio VGN-UX92S (small one) with a USB to Serial connection.
I can program the BB2 without any problems so the cable seems to be ok.
However when I try something as simple as the code below I get some strange results.

I tried different settings on the USB/COM port (change in packet size, latency etc…) but nothing is fixing the issue.

So using the code below, when opening the Terminal 1 in the IDE, you need to select 19.2Kbs to try it.

[code];The compiler will ignore any commands
;or text after a ; or ’

msg var byte
i var word

start

;this will sound 3 ascending beeps
sound 9,[150\2500, 150\3000, 150\3500]

loophere:
for i = 0 to 500
serin s_in,i19200,100,nextStep,[msg]
goto checkMsg
nextStep:
next

nextStep2:
pause 100

;repeat
goto loophere

checkMsg:
msg = msg + 1
serout s_out,i19200,[HEX msg,13]
goto nextStep2[/code]

Normally when you press a key in the output window it will be sent to the BB2 and the BB2 should return the HEX value + 1.

It works sometimes, but sometimes I get unrelated values appearing in the window.

Any idea what could be going on?

If I can get relialable COM with my PC I wonder how I will be able to control my 4WD :frowning:

Of course ideally I want an interupt based system but if I have already difficulties with the basic serin, then I can’t imagine with the interupt :slight_smile:

Laurent.

Hi Laurent.

This is a standard problem. Serin is a software only solution to read in serial information (commonly refered as bit banged). There is no hardware support for receiving your keyboard input. Theirfore it only works when the code is sitting in a serin command. So if you are luckly enough to hit your character when your code is sitting in the serin command it will work. If you are sitting in lets say the pause command it will miss it, if you are not in the serin when the character starts, but get in it before the character is done, you will get a wrong character. I hpe this makes sense.

There is one port on the Atom Pro that does have hardware support and specialized commands (Hserin, Hserout) to use it. It is on IO pins P14 and P15. The problem is that that these ports are TTL level and not RS232 signals and you would need to add a level converter to communicate. There are several threads with this in it.

Alternatively for robot control you can add some form of handshake betwen your program on the bot and your program on the PC. Again several threads talking about this.

I hope this makes sense and good luck.

Kurt

Yes I saw the Hserin documentation, knowing on which port it is will greatly help for sure.

I have a max232 lying around so I think I will use it to convert the level to RS232.

Thanks for the confirmation of what I had feared :slight_smile:
I will dig in more and hopefull I will have something working as I hope soon.

Thanks again.
Laurent.

Actually it is not a max232 that I have but a RS232 level shifter Board Kit from Sparkfun.
I also have the choice of using a FT232 USB breakout board…

I wonder which one I should choose…

Laurent.

My guess is either should work fine. You may have to make sure that you have 5v tollerance and the like. I think the USB breakout mentioned you need to desolder some jumper to remove a 3.3v… Might be a nice way to go as it leaves your USB to serial adapter connected to the main port to reprogram it…

Kurt

For the usb, I saw that mentionned into the documentation.
And indeed I should be able to keep the other one for programming and also for the output debug which could be very useful.

Being able to open the terminal from the Basic Atom IDE while programming in C++ on the MSDEV will surely be quite handy.
The good old printf debug :slight_smile:

Laurent.

Perfect.

I just hooked the FT232R and I have now my small test code working fine at 38400 and 125000 but not at 57600.
Well I guess 125000 will do then.

Now let’s try something a bit more complex :slight_smile:

Thanks Kurte for pointing me in the right direction.
Once I have something a bit presentable, I will send a link to my wiki.

Laurent.

Great!

Yeah, I think I had a PIC that wouldn’t connect at 57600 a few weeks ago. It worked fine at the bracketing frequencies. Maybe a baud % error from the divisor chain.

Alan KM6VV