Problem with rs232gui

alpert
Posts: 12
Joined: Mon Dec 19, 2011 11:32 am

Problem with rs232gui

Postby alpert » Mon Dec 19, 2011 11:50 am

Hello,
I have a problem with the rs232gui that I'm trying to solve for a long time.
I'm using a dspic30f4011, but i also tested it with dspic33fj256.
when I'm trying to start the rs232gui, it stops immediately and show error in the command window.

This is the model that I'm testing:
ex7_uart.mdl
The matlab Model
(41.06 KiB) Downloaded 151 times

(I've tried a lot of models, including sending a constant number)

This is the Error that i get:
2011-12-19_124311.jpg
Error massage
2011-12-19_124311.jpg (74.17 KiB) Viewed 5447 times


I'm using Matlab 2010b and blockset v3.7


What could be the problem?

Thanks,
Alpert

LubinKerhuel
Site Admin - Expert
Posts: 616
Joined: Wed Mar 07, 2007 11:23 pm
Location: Marseille - France
Contact:

Re: Problem with rs232gui

Postby LubinKerhuel » Mon Dec 19, 2011 1:43 pm

Alpert, you might try to press the Raw data button in the rs232gui interface.
No decoding will be done, you should get 1 control byte, and 1 value 1 control byte, 1 value etc....

Check that control byte is constant value, and that value is moving correctly (as it is an uint8, it does not need "reconstruction".)


You might check that your quartz is a 2.5MHz precisely.
Try removing I2C preipheral for testing UART only (IC2 will create problems if the I2C composant does not respond as it will freeze the software until timout take over the control)

The, try using a higher bandwidth (here, bandwidth is slow, but the UART is fully load as you try to send 2 char within one time step (1 control byte, 1 uint8 value) ) and the baud rate is too slow to send two byes within 1ms.
Try to get a baud rate for the UART with the lower % error possible (use PLL or change your quartz if necessary).

Note that the protocol used works better when sending several values, and when values are moving (as it makes control byte easier to find out the stream).

Lubin

alpert
Posts: 12
Joined: Mon Dec 19, 2011 11:32 am

Re: Problem with rs232gui

Postby alpert » Tue Jan 03, 2012 5:29 pm

Hello Lubin,
Thanks for your answer, and by the way, grate job with the blockset!
I have done a lot of experiments, and eventually I've discovered the problem.
I have done those steps:
1) I made a simple program (using your Simulink Blockset) that sand a constant number via the "Tx Output" block (not the gui), and I've set the "UART Configuration" to send at 115200 bps.
2) I connected my DSPic33 UART to my laptop and i watched the incoming data with "Realterm", and i changed the baud rate until i got on the screen the same number that i have send. The baud rate was 30,000.
3) I've made a new program. this time i've sent the data using the "TX Output Multiplexed for Matlab / Labview" block. again, I've set the "UART Configuration" to send at 115200 bps. then, i opened the rs232gui and i set it to recieve the data at 30,000. It worked!!!.

What could cause the different between the desirable baud rate and the actual baud rate? Why does it send at 30000bps when i set it to 115200?

I am attaching a simulink model that sample IMU sensors and send them using the "Tx Output". I'll appreciate if you look at it and see if i've done something wrong.


Thanks,
Alpert.
Attachments
ex8.mdl
(74.09 KiB) Downloaded 169 times

LubinKerhuel
Site Admin - Expert
Posts: 616
Joined: Wed Mar 07, 2007 11:23 pm
Location: Marseille - France
Contact:

Re: Problem with rs232gui

Postby LubinKerhuel » Thu Jan 12, 2012 11:01 am

Alpert,

With your quartz and no PLL, you get a 1.73% error on the UART baud rate.
This usually works but might be the problem(depending on your computer's hardware).

Try to activete PLL and find a processor speed that would lower the UART baud rate error (below 1% should be Ok !).


"2) I connected my DSPic33 UART to my laptop and i watched the incoming data with "Realterm", and i changed the baud rate until i got on the screen the same number that i have send. The baud rate was 30,000."
This is weird, but this is not a strong proof as if you're lucky enough, the UART will sample the signal and retrive the pattern corresponding to your constant. Please send an incrementing value and check you get abcdefg.... 12345... ABCD... on realterm. This is much better for testing.
Let me know if your finding is the same then.

Are you testing the Sparkfun UDB4 board ?

Lubin

alpert
Posts: 12
Joined: Mon Dec 19, 2011 11:32 am

Re: Problem with rs232gui

Postby alpert » Thu Jan 12, 2012 1:05 pm

Hi Lubin,
Thank you for your answer. I'll do some testing tomorrow morning.

I'm using now the sparkfun UDB4, but I have the same problem with the "Gluon Pilot" board.

Alpert.

LubinKerhuel
Site Admin - Expert
Posts: 616
Joined: Wed Mar 07, 2007 11:23 pm
Location: Marseille - France
Contact:

Re: Problem with rs232gui

Postby LubinKerhuel » Thu Jan 12, 2012 2:03 pm

I am willing to test this board.

First task for me is to embed a bootloader that would be quite practical.
I am planning to use the ds30 loader... then, using the clock switching option from the blockset, you could use the board very efficiently...

Lubin

alpert
Posts: 12
Joined: Mon Dec 19, 2011 11:32 am

Re: Problem with rs232gui

Postby alpert » Thu Jan 12, 2012 2:19 pm

Hello,
Bootloader for the UDB4 can be very useful !
I'm not familiar with the clock switching block. I'm not sure that i have it.

Until now I have check the Gyros and the Accelerometers on that board and the works fine. I have a problem withe the I2C, but i still not sure what cause that problem. i need to inspect it.

LubinKerhuel
Site Admin - Expert
Posts: 616
Joined: Wed Mar 07, 2007 11:23 pm
Location: Marseille - France
Contact:

Re: Problem with rs232gui

Postby LubinKerhuel » Thu Jan 12, 2012 3:11 pm

Hello Lior,

I get one board. I am willing to use it for personal project but I am quite overloaded right now.
You have clock switch options (something like) in the Master block.

this board has a 8MhZ quartz, not a 7.5 MhZ ?

I2C is always difficult to set-up!

Lubin

alpert
Posts: 12
Joined: Mon Dec 19, 2011 11:32 am

Re: Problem with rs232gui

Postby alpert » Thu Jan 12, 2012 6:40 pm

Hello,
I have done another test like you suggested. I've activated the PLL and I change the baud rate on the "UART Configuration" block, until i got in "Realterm" the same word that i've send from the simulink.
I've found that i need to set the block to 202700bps if i want it to send in 115200bps.

Here is the model:
ex9_led.mdl
(41.01 KiB) Downloaded 247 times


here is what i got in Realterm:
2012-01-12_192404.jpg
2012-01-12_192404.jpg (182.93 KiB) Viewed 5406 times



Its really weird..

LubinKerhuel
Site Admin - Expert
Posts: 616
Joined: Wed Mar 07, 2007 11:23 pm
Location: Marseille - France
Contact:

Re: Problem with rs232gui

Postby LubinKerhuel » Thu Jan 12, 2012 7:44 pm

In Master block, is there any reason why the quartz is set to 14Mhz this time ?
It should be 8Mhz !

Try to make one led blinking at 1Hz.
If it's not blinking at 1Hz, you have a problem with the oscillator configuration (thus UART cant be set at the appropriate baud rate)

Lubin

LubinKerhuel
Site Admin - Expert
Posts: 616
Joined: Wed Mar 07, 2007 11:23 pm
Location: Marseille - France
Contact:

Re: Problem with rs232gui

Postby LubinKerhuel » Sun Jan 15, 2012 12:38 am

Lior,

I did very first test with UDB4 board.
the attach model send Rate gyro and Accelerometers values through UART correctly using appropriate PLL value.
UDB4_TestBoard.mdl
Model for very first test with UDB4 board (Sparkfun) with Simulink and LK Blockset
(48.38 KiB) Downloaded 179 times

This is just for testing (plotting sensor in pseudo-real time). Note that baud rate used do not allow logging all 6 axis at 1kHz.

Lubin

alpert
Posts: 12
Joined: Mon Dec 19, 2011 11:32 am

Re: Problem with rs232gui

Postby alpert » Sun Jan 15, 2012 5:21 pm

Hello Lubin,
You were absolutely right about the clock. Yesterday I've done the test that you suggested with the 1Hz led, and i realized that my configuration of the clock were wrong. After i fixed that everything worked fine.

Thank you very much! You have done really grate job with your block set!
I hope not to write anymore at this part of the forum (Bug report).

Lior

LubinKerhuel
Site Admin - Expert
Posts: 616
Joined: Wed Mar 07, 2007 11:23 pm
Location: Marseille - France
Contact:

Re: Problem with rs232gui

Postby LubinKerhuel » Sun Jan 15, 2012 11:20 pm

I attached here the binary to use the bootloader ds30 (from Mikael Gustafsson) with the UDB4 board:

ds30_Bootloader_UDB4_Board_115200_UART2_ClkSwitchingEnable.zip
Binary File for ds30 bootloader on UDB4 Board (UART 2 - 115200 - ClockSwitching Enabled)
(19.69 KiB) Downloaded 185 times

==> Load this .hex into the board using classical programmer
==> then, use the ds30 GUI interface to upload new .hex. (Bootloader will be maintained on the board)

Bootloader binary is configured to use the UART2 (accessible on the board) at 115200.
Clock switching is enable (i.e. Simulink model to be loaded with the Bootloader might use any clock provided Clock Switching Enable is on in Master Block.)

Also attached is an update of the previous simulink model for UDB4 tailored for easy used with bootloader (no need to reboot the board : first attempt to program the board will stop the embedded software. Secodn attempt will effectively program it.):

UDB4_TestBoard.mdl
Simulink model with auto-reset when bootloader try to program the board. (and other features not described here...)
(73.41 KiB) Downloaded 173 times

Lubin


Return to “bug reports”

Who is online

Users browsing this forum: No registered users and 1 guest