Design rules concerning Servocontrol, receive RS232Commands

Moderator: Benj

Post Reply
beejo
Posts: 31
Joined: Thu Sep 11, 2008 12:46 pm
Location: TheNetherlands
Has thanked: 4 times
Been thanked: 1 time
Contact:

Design rules concerning Servocontrol, receive RS232Commands

Post by beejo »

Who can tell something about design rules concerning Servocontrol, receiving RS232 strings, the use of the internal Eeprom and the use of an LCDdisplay in one Flowcode-program of an Pic 16F877A controller?
Because for a long time I run up against unexpected results of servo moves and not received commands by RS232. I think that some of the flowcode macros as EEprom, RS232, Servo and LCD display works against each other. Probably the interrupt-vector is doing strange things.
Who can HELP me ?????
Beejo.

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Design rules concerning Servocontrol, receive RS232Comma

Post by Benj »

Hello,

The servo component uses interrupts which could be having a negative effect on your RS232 code if you are using the software UART.

The Hardware UART can also only buffer 3 bytes before it overflows so you need to make sure you try and receive the bytes into your program on a fairly regular basis. You could use the RXINT interrupt to receive a byte at a time and manually add to your string.

beejo
Posts: 31
Joined: Thu Sep 11, 2008 12:46 pm
Location: TheNetherlands
Has thanked: 4 times
Been thanked: 1 time
Contact:

Re: Design rules concerning Servocontrol, receive RS232Comma

Post by beejo »

Hi Benj,

Thanks that you are willing to help me.

I have to use: hardware UART, 3wire RS232 bus, 9800baud, 8 data bits and no flowcontrol.
I have no experience with Interrupt Handling. Can you show me how i can use the RXINT interrupt to read the bytes at a time? Maybe with a example?
And what do you mean with:"and manually add to your string."

Further another question.
Is there a need to follow a special order in the run of the different programm components such as read RS232, controll Servo, write internal EEprom, display servo positions on LCD and also is there a need to switch off certain macros before start an another macro?

Thanks in advance,
Beejo

beejo
Posts: 31
Joined: Thu Sep 11, 2008 12:46 pm
Location: TheNetherlands
Has thanked: 4 times
Been thanked: 1 time
Contact:

Re: Design rules concerning Servocontrol, receive RS232Comma

Post by beejo »

Hi,
I try to solve the problem to read an command in a reliable way by the RS232 in Flowcode4.5 prof.version. Maybe by making use of an RXINTInterrupt. BenJ gave this clue. I try several times but The Interrupt is also not working.
Someone can help me???
Beejo.

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Design rules concerning Servocontrol, receive RS232Comma

Post by Benj »

Hello Beejo,

If you enable the RXINT then assign a macro to it then that macro will be called when a byte is received. So inside the macro add a component macro call to read the byte from the RS232 component. You can then add the byte to an array or simply process it on a byte by byte basis.

beejo
Posts: 31
Joined: Thu Sep 11, 2008 12:46 pm
Location: TheNetherlands
Has thanked: 4 times
Been thanked: 1 time
Contact:

Re: Design rules concerning Servocontrol, receive RS232Comma

Post by beejo »

Hi Benj,

I think I have done what you told me but in simulation mode the interrupt does not work.
I am not sure about where to place the enable interrupt in the program. I have the feeling it have to be done before the while-1 command in the main prog.
I enable the RXINT interrupt before the While-1 statement and now I get a serious warning each time after compilation :

Serious Warning: Call stack usage exceeds:8!
Call Stack Usage Report
=======================
main and Task(s): hw used:5, exceeded by:0
interrupt: hw used:4, exceeded by:0

Never the less, I compiled the prog to the Pic 16F877A . The program react only once on a given RS232 command and do not switch off (second RS232command), the led in each program loop does not lit and the servo's... they have found their own live.
I try out why I have a usage of 5 on the stack and for that I deleted all action macro calls. So in the compilation the unused macros will be deleted in the compiled program. And indeed I get no warning.
Than I put one of the ten action macro calls in the main prog And after compilation I get the same serious warning.

Herewith I put, as attachment, the program with only the Main prog, the action macro who is responsible for the use of 5 stack places, the interrupt macro and the command filter macro.

Can you explain why the action macro “Pan to the left” takes so many stack room?
Why does the interrupt call needs 4 places on the Stack?
Is it possible to expand the stack?
Do I need to use another Pic controller to handle only the rs232 commands?
I hope that you can help me very soon with this.

Thanks in advance,
Beejo

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Design rules concerning Servocontrol, receive RS232Comma

Post by Benj »

Hello Beejo,

Sorry the RS232 receive interrupt does not work in simulation. Should run fine on hardware.
interrupt: hw used:4, exceeded by:0
It seems your interrupt macro is calling other macros. You should aim to keep your interrupt code as short as possible to allow other interrupts to come in. The best way is to set a variable in the interrupt macro and then process the data somewhere in the main by waiting for the variable to change state.

You can switch to the software stack if you run out of room on the hardware only stack. Details of how to do this are on the forums.

Post Reply