Prop1 RS-485 COMM using SN75176 to send Pelco commands
Falcon
Posts: 191
I'm attempting to use a Propeller to control the zoom function of a Pelco-D camera via an RC radio. My code is based on Duane Degn's RcReceiver6Demo121116a Object. I have the Prop1 reading and displaying the pulsewidth correctly. The CASE command is used to increase the speed of the zoom the further the joystick is moved from the (center) deadzone. This changes the zoom direction and zoom speed bytes.
I will use a SN75176 Differential Bus Transceiver chip between the Prop1 and the camera per this document: rs485Communication.pdf
I previously got this working with a PIC 12F683 using a SEROUT command, but now want to use the Prop1. The PIC used one pin to enable/disable communication, and one pin to transmit the data to the SN75176.
For the Prop1, I have the following circuit connections
SN75176 pin 6 to camera RS485+
SN75176 pin 7 to camera RS485-
SN75176 pins 2&3 to Prop1 pin 0 (enable/disable)
SN75176 pins 1&4 to Prop1 pin 1 (transmit)
Each Pelco command requires I send 7 bytes of hex data that includes a checksum. Example: Camera on = $FF,$02,$88,$00,$00,$00,$8A I have figured out all of the 7 byte commands so I don't have to do real-time checksum calculations.
The camera requires 2400 baud, No parity, true format.
I cannot get any response from the camera with the Prop1. I've tried the following code (using the FDS Object) but I'm not sure how to set the fds.start mode parameter.
RC_to_PELCO_Converter5_May_2013 - Archive [Date 2013.05.05 Time 18.04].zip
I also looked at the BS2_Functions Objec SEROUT Method but I'm not sure if I should use the SEROUT_CHAR Method or the SEROUT_STR Method to send 7 bytes.
Can anyone provide an example of a way to send those 7 byte commands.
falcon
I will use a SN75176 Differential Bus Transceiver chip between the Prop1 and the camera per this document: rs485Communication.pdf
I previously got this working with a PIC 12F683 using a SEROUT command, but now want to use the Prop1. The PIC used one pin to enable/disable communication, and one pin to transmit the data to the SN75176.
For the Prop1, I have the following circuit connections
SN75176 pin 6 to camera RS485+
SN75176 pin 7 to camera RS485-
SN75176 pins 2&3 to Prop1 pin 0 (enable/disable)
SN75176 pins 1&4 to Prop1 pin 1 (transmit)
Each Pelco command requires I send 7 bytes of hex data that includes a checksum. Example: Camera on = $FF,$02,$88,$00,$00,$00,$8A I have figured out all of the 7 byte commands so I don't have to do real-time checksum calculations.
The camera requires 2400 baud, No parity, true format.
I cannot get any response from the camera with the Prop1. I've tried the following code (using the FDS Object) but I'm not sure how to set the fds.start mode parameter.
RC_to_PELCO_Converter5_May_2013 - Archive [Date 2013.05.05 Time 18.04].zip
I also looked at the BS2_Functions Objec SEROUT Method but I'm not sure if I should use the SEROUT_CHAR Method or the SEROUT_STR Method to send 7 bytes.
Can anyone provide an example of a way to send those 7 byte commands.
falcon
Comments
I run PTZ cameras from the Prop using a standard PS2/USB keypad. The reason is that I normally only need preset positions and zoom so it's easy to run this from the Prop plus it's being used for other things anyway. I can also enter a manual mode where I use the keypad to manually PTZ with accelerating key functions the more I press the same key. The manual mode is used to initially setup the camera's preset positions after which it becomes a simple [CAM] + [0..9] to go to the presets.
I have several PTZ cameras in my home security system and use either a stand-alone hard-wired controller, DVR commands or an IR controller, depending on the situation.
falcon.
I now have communication with the camera. I'm using the SN75176 I have on hand vs. the MAX485, but it works.
Duane Degn's RcReceiver6Demo121116a Object works like a charm in reading the RC Receiver and displaying the pulselength.
The one last problem I have is getting the pulselength to control which block of code is sent to the camera. I changed the code to control the Pan function since it's easier to see a result. The zoom is an internal (but optical) movement.
My approach is to use a CASE statement. The joystick center is around 1500 uS. I'll add a deadband for hysteresis when I go back to the Zoom code. Below 1500 uS the Prop1 would send the block of code to Pan Right. Above 1500 uS the Prop1 would send the block of code to Pan Left I thought I had the CASE statement formatted like the Prop Manual but I don't get any movement. I did move the following line of code to the end. The pulselength is displayed on the PST.
I figured the CASE statement needed to see the pulselength before it is reset. I hope I'm right there.
So, did I get the CASE statement wrong?
Is there a better way? When I revert back to the Zoom function I will break the pulselength range into 8 zones and adjust the zoom speed based on joystick displacement.
Latest code:
RC_to_PELCO_Converter_7_May_2013 - Archive [Date 2013.05.07 Time 18.59].zip
falcon
I rule!
You may be having a problem with the code in that you are checking to see if the current reading is the same as the last -- but with a joystick and a possible range of 1000 to 2000 there could be some wiggle. Figure out what your input range is and then divide that by the number of zones you want to handle. For starters, use 3 (left, stop, right). If the receiver is giving you 1000 to 2000 you might do something like this:
That worked like a charm.
I will want a smaller "dead" zone so I think I can use something like:
I appreciate your, and everyone's, help.
falcon