RS232 conflict with Servo?

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 4.
To post in this forum you must have a registered copy of Flowcode 4 or higher. To sign up for this forum topic please use the "Online Resources" link in the Flowcode Help Menu.

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:

RS232 conflict with Servo?

Post by beejo »

Hi,
I am trying to use the RS232 module in Flowcode 4.5 to receive commands in a PIC16F877A(“The receiver”) and to control two servo motors.

To test the program, I use two EB006 PIC program boards.
One to control the servo’s as an RS232 Receiver or to use as an direct Hand-control (5 switches), called “the Receiver”. The other to simulate an sort of modem to remote control the servo’s, called “the Sender”. Both programmers are connected with 2 RS232 boards. The boards are joined with a crossed cable.
The Receiver board is an EB006 version 7 and the Sender board an EB006 version 6.

Each program board have an led board on port A, a switch board on port B and a RS232board (EB015) on port C.
The led board of the Receiver displays the actions of the servo’s. Led A0 from the led board of the Sender displays that an command have been send.
The command is an hex string with a length of 20 bytes where actually max 10 bytes are used to send these commands.
The properties of the RS232 module in Flowcode are :
9600 Baudrate.
No flowcontrol.
TX/RX = UART1.
Databits = 8.
Chartype = Int(extended mode). End of the command string= 0xFF
RX timed out units = legacy .
Echo mode = V.
Simulation Bytes.
Show simulation V.

On port D of the Receiver an LCD board EB005 is connected to monitor the actions (Position) of both servo’s or monitor the received RS232 commands.
If an good RS232command has been received this command is displayed instead of the position of the servo’s.
Now I have seen that the commands arrive in the Receiver PIC, I delete that display option to save Stack room.

The connection of the “Receiver” is made via an 1:1cable (full wired DB9 connector except the two servo’s connection pins C3 and C4) from Receiver Port C to bus J3 (To PICboard) of an EB015 board. The motor connection pins Pin C3 and C4 of the “Receiver” board are separated and lead directly to the Yellow coloured wires of the servo’s. The 5V power of the little servo’s comes also from the Receiver board.

The “Sender” board EB006v6 is directly connected via Port C with bus J3 of an EB015 board
Both EB015 boards are connected with each other by an 3 wired crossed cable between both J1 connectors:
Receiver pin2 to Sender pin3, Receiver pin3 to Sender pin2. Receiver pin5 to Sender pin5.

To position the servo’s I have the choice two use 5 knops (Hand control) on the receiver board or to use a sort of modem (“The sender”) to remote control the servo’s by RS232.

The Hand control on the Receiver board always works fine.
When the receiver received an good RS232 command the concerning RS232Flag is set and depending of the status of the flag the program jumps to the same routine as the hand control used for that action. Of course the while and decisions statements of the servo routine’s takes into account the status of the RS232Flag.

The “Sender”, simulated by the EB006v6 board, sends an command initiated with a push on one of the 5 dedicated switches on the switchboard EB007. The send program register if the knob has released and then sends a break command to the receiver. That causes the RS232Flag in the receiver program becomes zero. The subroutine is halted and the program goes to the main program. The main program checks continuously the switch port (Port B) and RS232activity.

As soon as the receiver receives an action-command the receive program jumps to the associated motor action and have to stop this action when the RS232Flag is changed or when the servo positioning arrived the software limit.

Both servo’s work excellent with the switch control on the receiver board : Left, right ,up, down and centre/reset.

I had some difficults to receive RS232commands. But know it seems that the Pic receive the commands but don’t handle it right. Because I made a loop to display the received commands I have seen that the RS232 transmission works. But only one of the servo functions (the centre/reset function) works good. The "move right" command starts and don’t react on the stop command, the tilt down command causes jitter on both servo's at the same time, the other command does'nt react at all. So as I said rather, in the Hand mode all functions works always fine.
In Simulation mode I used Flowserver.exe to simulate an RS232 connection with the programs Receive and Send and it works rely nice. But in real mode ……….

I have the impression that some registers come in conflict and the program is not following the normal direction.

What can I do?
Is there anybody who can help me here with ??

Greetings
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: RS232 conflict with Servo?

Post by Benj »

Hello Beejo,

Are you using any interrupts in your program? For example a UART receive interrupt or any timer interrupts? Could be that the servo interrupt is going slightly out of sync if there are other interrupts with larger service macros present on the system.

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

Re: RS232 conflict with Servo?

Post by beejo »

No, only the RS232 module from flowcode. I don't know if they make use of a interupt routine.
Joh.

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: RS232 conflict with Servo?

Post by Benj »

Hello Beejo,

No the RS232 component does not use any interrupts by default.

Could you post your program onto the forums or send to me via a PM if it is commercially sensitive and I will see if I can spot any cause for the problems you are experiencing.

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

Re: RS232 conflict with Servo?

Post by beejo »

Hi BenJ ,

I have send you two pm's with the programs enclosed.

Regards,
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: RS232 conflict with Servo?

Post by Benj »

Hello Beejo,

I notice in your receiver program you are using the EEPROM component. This essentially temporarily disables the Interrupts to ensure the EE data goes in correctly. Could you maybe disable your servo outputs temporarily before writing to the EEPROM and enable again afterwards? This may get rid of the movement error you are experiencing.

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

Re: RS232 conflict with Servo?

Post by beejo »

BenJ,
That sounds great i never came up on that link. Tomorrow i shall try this in simulation mode and next monday in practice. Because i am not in the office till monday.
I inform you as soon as I know something more about it.
Regards,
Beejo

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

Re: RS232 conflict with Servo?

Post by beejo »

Hi Benj,

I disabled the servo’s before any read or write action of the EEprom. The result is that the Receive program accept all the commands except the stop-command. This is a really nice thing but only the Stop command is not always seen by the Read-RS232routine.

I notice when the timeout value of the RS232 Read macro is set to the max value (255) the Stopcommand works a much better. But the servo become realy slow.

The stop command is given automatically as soon as an switch from the Sender has been released.
In the ReadRS-232 macro the commands are filtered. First is it an real command? and than is it an Stop- command or an another servo-command? When it is a real command the led D5 will be lit to show there is an accepted command arrived. Then the routine search for which command is given and the affined RS232Flag is set. When it is an stop command the RS232Flag is set to 0 and the Led D5 is disabled to show the stop command is accepted by the program.
In some cases the led disabled (but mostly not) and the servo then stop immediately. So the program mostly cannot detect the stop command.
With Micterm.exe* I watch the commands on the com1 port from the PC connected to J2 (To Modem) of board EE015 on the Receiver side. If an servo command is given I always see an good servo command followed by an good stop command.

In simulation mode it works perfect (The Receiver with the Vnet-server and the Sender program).
Yesterday I spent the hole day to search in the the program.
I can not figure out why the stopcommand mostly is not seen by the read RS232 routine.

Would you have a look to the program against?
Thanks in advance,
Joh.



* Micterm.exe is an free download program (written by Bert van Dam. Writer among other things the book: “Microcontroller System Engineering”)

Post Reply