RS232 conflict with Servo?
Posted: Tue Oct 04, 2011 1:12 pm
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
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