Remote control of FLIR PM series cameras using Arduino & RS232 - a mini project - Page 1
Forum section: electronics / general

author: Fraser
author_rank: Super Contributor
timestamp: October 30, 2016, 12:32:00 pm
content: Hi all,I am about to embark on a little remote control project that may be of interest to others on this sub forum ?I own several FLIR PM series industrial thermal cameras. These have a built in keypad and joystick to access functions via a menu. There is also a very rare and expensive remote control handset option that can control the camera via the 10 pin LEMO 2B 310 RS232 communications port on the side of the camera.FLIR were kind enough to publish the full RS232 port command set for these cameras so that owners can control them from a simple RS232 terminal or PC. Thankfully no specialist communications adapters or translators are required so it is a simple RS232 cable link.I own three of the official remote control handsets and was surprised to find a fully fledged single board computer within them. IIRC it uses a MC68000 but I would need to check that as it was a long time ago. The SBC is basically a computer running a terminal program with macro keys as the input and RS232 as the command string output.I intend to replicate the functionality of the OEM remote using an Arduino Nano board, some buttons and a UART TTL to RS232 converter. The OEM remote has 12 buttons on it but there is no reason why I could not build a 'super' remote that can send more commands to the camera as there are masses available for the remote control of the PM series cameras.AGEMA designed the PM series platform that was bought by FLIR and the design is well thought through, as is typical of AGEMA products. The remote control functionality is comprehensive to say the least. There is a single command string with a variable that may be set to replicate every physical button or joystick movement on the camera. This basically provides GUI menu control of the camera. Alternatively, there are also direct commands for functions such as setting emissivity, zoom, auto focus, span, level, ISOtherm, spot metering point and other useful features. The capabilities of remote control over these cameras is limited only by the number of command buttons you want on the remote control, or within a PC software control application. These are truly versatile cameras.One of my FLIR PM series cameras is a 'Box Camera' These are the type fitted in the gimbal mounted sphere that police helicopters etc carry. There is just one LEMO combined communications and power port, and one BNC connector for video output on the camera. It has no buttons or EVF. The camera is designed to be remote controlled from a location remote from the camera or in a lab using the PC software and video capture interface that came with it. My 'Box Cam' is new unissued stock and I have been keen to play with it on a Pan Tilt mount using a dedicated remote control and LCD monitor. Great for wildlife observation at a distance.I now have a stack of Arduino UNO R3, MEGA and Nano boards to experiment with. This is one application for which the Arduino appears very well suited. Hopefully it will provide a means to create what I need quickly and simply. I am just starting out with Arduino so it will also serve as a self teaching project on programming these versatile little microcontrollers. I am also learning embedded C and writing code for PIC IC's, but the Arduino can do this sort of task so simply and the Nano actually comprises almost all the required parts for a remote, bar the switches and true RS232 adapter.I shall document my progress with this little project here and share the Sketch for use by others with a similar need. The remote could control any camera that has documented serial RS232 commands. The FLIR industrial cameras always used to include a RS232 port but sadly later models are USB only.Watch this space and any/all comments and suggestions are welcome. Let's just keep away from the Arduino Vs PIC type discussions though ehThe cameras that I will be controlling with the remote are listed belowAGEMA PM570FLIR PM570FLIR PM575FLIR PM695FLIR SC500FLIR SC3000Other cameras with the same remote control commands and port are:FLIR PM525FLIR PM675The FLIR P series also has a serial remote control port but I cannot confirm that the commands are the same as on the PM series. Easy enough to change the commands in the Arduino Sketch though.Fraser

author: retrolefty
author_rank: Super Contributor
timestamp: October 30, 2016, 12:53:31 pm
content: sounds cool, I will be following.

author: Fraser
author_rank: Super Contributor
timestamp: October 30, 2016, 02:39:22 pm
content: Every project should have at least a simple statement of requirements so here is such for this little remote control.Project: Remote control commander for FLIR PM series camerasStatement of requirements1. Format: Handheld2. Communications type and bearer: True RS232 via cable and LEMO 2B-310 Plug3. Input method: Push buttons. Number set by functions to be provided.The minimum will be 8 functions.OEM remote control handset Functions:Camera button simulation:Enter ButtonEscape ButtonStore ButtonAuto Adjust ButtonNavigation Up buttonNavigation Down buttonNavigation Left buttonNavigation Right buttonAdditional functions on remote control:LevelSpanEmissivityDistance4. Power supply : Provided by host. 11-16 V DC @<250mA5. Keypad type: Individual push buttons per function. No auto-repeat.6. Output Command type: RS232 serial string in ASCII7. Microcontroller board: ARDUINO UNO R3 or Nano8. RS232 settings used by the camera:19200 baud default (options for 9600 & 38400 via RS232 commands)1 start bit, 8 data bits, No parity, 1 stop bitXOn/XOff flow control9. Example output command string:Command: button:<button ID goes here>[,<p or r>] CRThe button ID is detailed in the documentation and will be one of the following:ent / esc/ f1 / f2 / u / r / d / l / lev / spn / emi / dstThe 'p' is to indicate button 'pressed' and the 'r' is button 'released'If only 'button pressed' is used, the camera auto releases the button after 2 seconds.Answer from the Camera to each command argument: OKTo send STORE function to camera, the command will look like:button:f1,p button:f1,r To send AUTO ADJUST function to the camera, the command will look like:button:f2,p button:f2,r

author: Fraser
author_rank: Super Contributor
timestamp: October 30, 2016, 02:55:41 pm
content: Some notes of my thoughts regarding this project to date:1. A simple remote with few buttons will likely use individual push buttons and no matrix. A more complex remote with many buttons will likely use either a matrix push button keypad or one of the encoded capacitive keypads, and associated library.2. The buttons need to have contact de-bouncing incorporated into the sketch.3. The serial commands string link uses Xon/Xoff flow control. This needs to be further investigated with regard to Arduino serial string transmission and flow control.4. The serial output from the Arduino will need to pass through a UART to RS232 converter such as the MAX3232 for inversion and level changing.Fraser

author: Fraser
author_rank: Super Contributor
timestamp: October 30, 2016, 03:04:13 pm
content: The OEM FLIR remote control that is so rare and expensive.

author: Bill W
author_rank: Super Contributor
timestamp: October 30, 2016, 04:00:51 pm
content: Hi Fraser,One other option, unless you have already discarded it, would be to use a TV remote controller for the buttons. Should just go straight from the receive opto transistor onto one pin of the micro.Philips is the best documented command set, or perhaps Hauppauge WinTVregardsBill

author: Fraser
author_rank: Super Contributor
timestamp: October 30, 2016, 04:16:34 pm
content: Hi Bill,Yes a good idea. I was starting out with the simplest format of a simple button connected to the Arduino as part of a base line to start from. I may well look at the IR link keypad once i have made sure the most basic serial commander actually works. That is the joy of the Arduino of course. It is so simple to change the input configuration from switches to something like Philips RC6. As you will see in my next post, I have a couple of Nano dev boards and one has the IR receiver fitted alreadyThanks for the suggestion. It will be investigatedFraser

author: Fraser
author_rank: Super Contributor
timestamp: October 30, 2016, 04:19:32 pm
content: For those interested in some of the Arduino related development stuff I have collected together over the past few weeks, here are some pictures of what I bought.I have been meaning to dive into Arduino for a while but did not have the incentive to do so. Now I doI presently have several UNO R3 boards, both 'Genuine' and clones, several Nano's, all clones, a Leonardo clone, and a Mega clone.I can provide details of where I bought them if desired. They are soooo cheap !As you can see I also bought a little portable variable power supply for when I am developing 'on the road' and away from my lab supplies etc.I have other Arduino related stuff, but this is what I will be using for my initial projects and learning experience.Fraser

author: Fraser
author_rank: Super Contributor
timestamp: October 30, 2016, 04:21:20 pm
content: The development bits.......

author: Fraser
author_rank: Super Contributor
timestamp: October 30, 2016, 04:33:35 pm
content: Pretty much all I need for IR control is to be found here.https://arduino-info.wikispaces.com/IR-RemoteControlThat option will be explored but will not be part of the first development phase as I need to ensure the core serial control functionality works as expected with the camera.Fraser

author: Chanc3
author_rank: Frequent Contributor
timestamp: October 30, 2016, 08:40:20 pm
content: Having created a C# application to control the FLIR PM695 infrared camera wirelessly using handywave rs232 transceivers, I shall be following this with great interest!Any chance you have a spare remote?Sent from my iPad using Tapatalk

author: joe-c
author_rank: Frequent Contributor
timestamp: October 30, 2016, 08:49:20 pm
content: i know the tiny RS232pcbs.see here:http://joe-c.de/pages/posts/rs232_pegelwandler_149.phpand they don't like a connection to an active transmitter without power supply.i had used a µC and this chip connected to a USB-RS232 adapter. after a short pull out and re plug the communication don't work and the chip gets hot.but for me its a really nice device, its small and cheap

author: Fraser
author_rank: Super Contributor
timestamp: October 30, 2016, 09:32:49 pm
content: Thanks chaps.Joe CVery interesting to hear that the little MAX3232 IC has a vulnerability if unpowered.Chance3I have three FLIR remotes but the last one I saw sold went for £400 !This is why I thought I would make my own using the Arduino. A DIY version may be built to the users needs as well. I am already collecting together various switch type joysticks etc and considering different formats of remote unit. As Bill suggested, I may even make a RS232 'dongle' that takes IR commands from an RC6 coded IR remote control and sends the associated serial command to the camera. I have such a unit for my Lowe HF150 receiver.The more I look at these little cheap Arduino units, the more I see a product that is designed to be very easy to program yet very versatile. A sort of Swiss Army knife of microcontrollersFraser

author: Fraser
author_rank: Super Contributor
timestamp: November 01, 2016, 03:04:36 pm
content: Just a quick update...Sketch is coming along nicely but yet to be tested on the camera.I have bought a selection of keypad and joystick types for experimentation. I even bought a car wing mirror adjustment joystick as these are a switch type and usually well built. I am hoping to replicate the PM series joystick that is used for menu navigation. Keypads come in all manner of formats and communication types. I have examples of basic switch matrix, analogue resistance and capacitive touch types.I just need some spare time to rig it all up to test on camera. Many demands on my time at the moment though.Fraser

author: paradigmic
author_rank: Contributor
timestamp: November 05, 2016, 05:18:52 am
content: Looks like you're all set for hardware. For software, I found these (Windows) tools useful:TerminalIt's a virtual serial terminal so you can send/receive data over serial. Also good for logging and verifying your program is doing what you think it does.https://sites.google.com/site/terminalbpp/com0comThis is a driver that creates a pair of virtual serial ports. I used it with Terminal to capture the serial output of some programs to see what they were sending.http://com0com.sourceforge.net/

author: apelly
author_rank: Unknown
timestamp: November 05, 2016, 05:57:15 am
content: Subscribed. It's of no use to me whatsoever, but it sounds interesting enough. I'm keen to read about your progress.

author: joe-c
author_rank: Frequent Contributor
timestamp: November 05, 2016, 09:22:16 am
content: If you need a terminal program for serial communication with source you can use this:http://joe-c.de/media/all/dev/cs_dev_tools/1.JPGimplant additional buttons to send special command sequences is simple with c#download here:http://joe-c.de/pages/posts/programm_dev_tools_133.php#Download

author: Fraser
author_rank: Super Contributor
timestamp: November 05, 2016, 12:29:45 pm
content: Thanks Joe C. Much appreciated

author: Fraser
author_rank: Super Contributor
timestamp: November 05, 2016, 12:31:33 pm
content: Paradigmic,Many thanks

author: Fraser
author_rank: Super Contributor
timestamp: November 11, 2016, 10:41:32 pm
content: Update:No progress on this little project yet as I have been working on other projects, such as repairing some more thermal cameras and a nice little Advantest Spectrum Analyser. I will get back to this project ASAP.Fraser

author: Hard_ware
author_rank: Newbie
timestamp: November 29, 2016, 01:48:07 pm
content: Here is the sketch I am using for the e6000 thermaljust some examples of of ways to send the serial data may not be the best as I only have been playing with the arduinos for couple of months, the real time potentiometer controls allow adjusting the gain and level very precisely 1 bit changes.not sure if flir uses a check sum, but e6000 was simple 256=whatever you send has to total 256 so last byte had to make up the difference which is the checksumArduino nano source code for 6 button remote with manual gain and level controlsSwitches go to gnd and respective pins labeled in program d4-d9 on nano PCBPotentiometers 1 & 2 are 10K outer pins connected to gnd and 5v labeled on nano PCB thencenter pin or wiper connected to A3 (gain potentiometer #1) and A5(level potentiometer #2) labeled on nano PCBgnd------A3-------5v (pot#1) gnd-------A5---------5v (pot#2) labeled on nano PCBNote: to reprogram the arduino nano that's connected to a RS232 to TTL PCB board you have to disconnect the TX and RX pins from the nano PCB to the rs232 PCB. The wires going to the camera can stay connected, as well as the buttons.Only 2 wires need to be disconnected the rx and tx from the nano to the RS232 PCBafter reprogramming reconnect the TX and RX back, if you don't disconnect you can't communicate with the nanoTested and workingCut and paste this code in arduino IDE program windowStart below#include <SoftwareSerial.h>#define DEBOUNCE 100 // ms for Debounce, 5+//Buttons.byte buttons[] = {4, 5, 6, 7, 8, 9};//Figure out Array Size#define NUMBUTTONS sizeof(buttons)//Track Buttons Pressed, Released, Currently Pressedbyte pressed, justpressed, justreleased;byte previous_keystate, current_keystate;//define variablesint bhot=1;int narrow=1;int manual=0;int mgain=120;int mlevel=125;int mgain2=125;int mlevel2=200;void setup() {byte i;Serial.begin(19200); //Setup Serial Port// Input and Enable Pull-Up Resistors for Switch Pinsfor (i=0; i< NUMBUTTONS; i++) {pinMode(buttons, INPUT);digitalWrite(buttons, HIGH);}}void loop() {analogRead(A3); //Discardint level=analogRead(A3);analogRead(A5); //Discardint gain=analogRead(A5);mgain=map(gain,0,1023,190,220);mlevel=map(level,0,1023,00,255);byte ccsum=256-1-50-2-15-mgain;byte bcsum=256-1-51-2-7-mlevel;byte thisSwitch=thisSwitch_justPressed();switch(thisSwitch){case 0:// button 1 NUC with shutter pin D4Serial.write(0x01);Serial.write(0x27);Serial.write(0x02);Serial.write(0x00);Serial.write(0x03);Serial.write(0xd3); break;case 1:// button 2 TOGGLE POLARITY pin D5if(bhot==1){Serial.write(0x01);Serial.write(0x28);Serial.write(0x00);Serial.write(0xd7);bhot=bhot-1; break;}elseSerial.write(0x01);Serial.write(0x29);Serial.write(0x00);Serial.write(0xd6);bhot=bhot+1; break;case 2:// button 3 MANUAL AGC MODE pin D6Serial.write(0x01);Serial.write(0x2a);Serial.write(0x02);Serial.write(0x00);Serial.write(0x02);Serial.write(0xd1);delay(100);manual=1;Serial.write(0x01);Serial.write(0x32);Serial.write(0x02);Serial.write(0x0f);Serial.write(mgain);Serial.write(ccsum);delay(100);Serial.write(0x01);Serial.write(0x33);Serial.write(0x02);Serial.write(0x07);Serial.write(mlevel);Serial.write(bcsum);delay(100);break;case 3:// button 4 STANDARD AGC pin D7Serial.write(0x01);Serial.write(0x2a);Serial.write(0x02);Serial.write(0x00);Serial.write(0x01);Serial.write(0xd2);manual=0;break;case 4:// button 5 TOGGLE FOV pin D8if(narrow==1){Serial.write(0x01);Serial.write(0xa4);Serial.write(0x00);Serial.write(0x5b);narrow=narrow-1;break;}else {Serial.write(0x01);Serial.write(0xa5);Serial.write(0x02);Serial.write(0x00);Serial.write(0x00);Serial.write(0x58);narrow=narrow+1;break; }case 5:// button 6 MANUAL AGC OFF pin D9Serial.write(0x01);Serial.write(0x2a);Serial.write(0x02);Serial.write(0x00);Serial.write(0x00);Serial.write(0xd3);manual=0;break;}}void check_switches(){static byte previousstate;static byte currentstate;static long lasttime;byte index;if (millis() < lasttime) {// We Looped, One More Timelasttime = millis();}if ((lasttime + DEBOUNCE) > millis()) {// Not Enough Time Passed for Debouncereturn;}// DEBOUNCE Milliseconds, Reset the Timerlasttime = millis();for (index = 0; index < NUMBUTTONS; index++) {justpressed = 0; //Clear Out Indicatorsjustreleased = 0;currentstate = digitalRead(buttons); //Read Buttonif (currentstate == previousstate) {if ((pressed == LOW) && (currentstate == LOW)) {// Just Pressedjustpressed = 1;}else if ((pressed == HIGH) && (currentstate == HIGH)) {justreleased = 1; // Just Released}pressed = !currentstate; //HIGH means NOT pressed}previousstate = currentstate; //Running Count of the Buttons}}byte thisSwitch_justPressed() {byte thisSwitch = 255;check_switches(); //Check the Switches ; Get Current Statefor (byte i = 0; i < NUMBUTTONS; i++) {current_keystate=justpressed;if (current_keystate!= previous_keystate) {if (current_keystate) thisSwitch=i;}previous_keystate=current_keystate;}analogRead(A3); //Discardint level=analogRead(A3); // center pin of potentiometer #1analogRead(A5); //Discardint gain=analogRead(A5); // center pin of potentiometer #2mgain=map(gain,0,1023,190,220);mlevel=map(level,0,1023,00,255);byte ccsum=256-1-50-2-15-mgain;byte bcsum=256-1-51-2-7-mlevel;if ((manual==1)&&(mgain2!=mgain)) {Serial.write(0x01);Serial.write(0x32);Serial.write(0x02);Serial.write(0x0f);Serial.write(mgain);Serial.write(ccsum);delay(100);mgain2=mgain;}if ((manual==1)&&(mlevel2!=mlevel)) {Serial.write(0x01);Serial.write(0x33);Serial.write(0x02);Serial.write(0x07);Serial.write(mlevel);Serial.write(bcsum);delay(100);mlevel2=mlevel;}return thisSwitch;}Ended above this lineHere is how I mounted the RS232 to TTL boardVideo of potentiometer adjustment of gain and levelhttps://youtu.be/H6LsBBytTxk

author: Fraser
author_rank: Super Contributor
timestamp: November 29, 2016, 02:26:11 pm
content: Hi Hard wareThank you so much for sharing your work. I feel sure I can learn from it.I am still at 'Ground Zero' with my Arduino learning experience. I am actually finding the C programs pretty friendly and easy to follow. I have a few books I am reading on the basics and best practices etc.My sketch will initially be very simple compared to yours. It just contains the following elements....Setting up input pins from hardware buttons. Including pull up'sEnabling serial at 19200 8N1Reading button inputsSending appropriate serial string for a button pressed (simple "button:(function) CR for each button).Small debounce delay of say 50mSSending appropriate serial string to tell camera button is released (it is a camera requirement)Back to reading button inputs.There will initially be only 8 button inputs to provide a 4 way navigation pad/joystick and four direct function buttons.I may expand the number of button inputs to twelve to replicate the FLIR remote control. Proof of concept first though.Enhanced versions of the unit will follow.....1. Different types of keypads and joysticks (analogue and digital)2. Direct function buttons beyond those on the FLIR remote3. IR remote control input that uses common RC6 remote4. RF remote using keypad encoder/encoder and ISM band TX/RX pair.I will also add analogue controls to this list. I had not even considered such to date. The camera programming manual details all the commands needed for direct value entry and step up/down on things like span and levelThank you for this most excellent idea. It will be better than the camera or official remote offered...... I like physical knobs!This is just a fun little project for me to play with as I do have the official FLIR remotes, but it is fun to make a custom controller for the camera and probably a superb compact motorised camera mount that I also just purchased.So many distractions at this time of year though. I just need to quiet time to sit down and concentrate whilst writing the C program and testing it. I have a veritable pile of different Arduino board formats and accessories to play withMany thanks againFraser

author: Hard_ware
author_rank: Newbie
timestamp: November 29, 2016, 07:20:33 pm
content: Very welcome!I had fun making this controller and now have a way to send serial data for what ever comes up in the future.