Putting robotics at your service™

Free shipping on orders over $200

Communication Problem, C++(Matlab) Solved...

Print view Share :
Previous topicNext topic

Page 1 of 1 [ 7 posts ]

New ( offline )
Posts: 4
Posted: 2008-04-22 13:35 
We bought the 'Autom Bot Board' and met a problem:

It cannot get message from other program(Matlab or c++) from serial port RS232.

However, it works with Basic Atom Pro. We can send seem instructions from Debug windows of Basic Atom Pro and it works, but not from c++.

The communication was ok between two computers with both programs.

What the difference? Is there any special set in Basic Atom Program?

who knows, please help me! Thanks a lot!

User avatar
Guru ( offline )
Posts: 4890
Posted: 2008-04-22 15:02 
On the Atom, Atom Pro and maybe others the RS232 communication to the DB9 connector is done using bit bang functions and not using underlying hardware support. The underlying hardware H8 does have a hardware serial port that is connected to the external IO pins P14 and P15, but they are TTL level signals and not RS232 level signals.

You have a couple of choices, you could either write your own bitbang functions to talk to your debug window. I have been meaning to do this for the PRO for the same reasons. I debugged my last C code by turning on the BB2s LEDS for different conditions. I posted that code a few days ago with my I2C support functions...

Alternatively you could connect up something like a MAX232 chip to P14 and P15 to convert to the appropriate signal levels and then connect it to a DB9 connector...

New ( offline )
Posts: 4
Posted: 2008-04-23 03:34 
Thanks a lot!

I use DB9 port.

Do you mean i must use Basic Atom when running my program(c or matlab) if i do not change hardware?

my code of Basic for test is as :
comando var byte
serialInput var byte(8)
x var byte
speed2 con 1000

enablehserial 'enable hardware serial
sethserial H9600,h8databits,hnoparity,h1stopbits


serin s_in, i9600, [comando]
if comando = 77 then
serout s_out,i9600,[x]
goto loop

Then I use 'readfile' and 'writefile' in C++ to connect RS232.

User avatar
Guru ( offline )
Posts: 4890
Posted: 2008-04-23 10:30 
On the Atom Pro, you have a choice. You can either use the basic or you can program the whole thing in C or C++, you can not mix the two. You can mix Basic with H8 assembly language. Assuming you have a 28 pin Atom Pro, you should have the H8/3694.

It would be great if Basic Micro exported a set of libraries that allow you to use their software functions, or alternatively, defined some form of interface that allowed you to add external modules that were callable from their basic. However that is not currently the case.

So in the mean time, it would be great if members who write something in C (or C++ or assembly) would post their code so others could use it. That is why I posted my first version of the I2C code (which I will rework to add more asyncronous support). maybe I will break down and import my serial bit bang functions from the AVR so I can debug this easier...

Good Luck

New ( offline )
Posts: 4
Posted: 2008-04-24 13:17 
 Post subject: hyperterminal
Thank you very much!

The person said that, the wireless do not need changing of hardware.

i can use hyperterminal and Basic Autom to connect the control board!

but any other program! Why?

New ( offline )
Posts: 4
Posted: 2008-04-29 11:52 
 Post subject: I solved my problem
The problem was sloved.

At first, the person responsible for hardware told me that there was no flowcontrol. So I tried many ways and set none flowcontrol.

Failed again and again! However, I found that both Basic Atom and hyperterminal are ok for cable and wireless. Even here, I set flowcontrol as 'none'.

Have no choice, tried every software! vb, vc, and matlab. I even want to find the origional code of hyperterminal. Still no help!

So, I checked and adjust each parameter. Finally, I found that the flowcontrol should be "Hardware or Dtrcontrol".

Then all program work now!!!!

Rookie ( offline )
Posts: 38
Posted: 2009-08-17 23:52 

I am having a similar problem. I am trying to give commands serially through Matlab. Matlab says the bytes are being written but the robot does not move.

I am wondering if you changed this flowcontrol on matlab to be 'hardware'? For me, some other programs work with no flowcontrol.

If I do change however, I get this error while trying to write 255 (one byte):
>> fwrite(s, [255])
??? Error using ==> serial.fwrite at 184
FWRITE can not be called when FlowControl is set to hardware and the PinStatus clear to send (CTS) field is off.

How do I change this pinStatus CTS field? Did you do that and it started working?


All times are UTC - 5 hours [ DST ]. It is currently 2014-08-02 00:29
Feedback Form
Feedback Form