I would like to program the operation of a winch. I have purchased this remote that lets me in/out the winch but I would like to use an UNO so I can program the in/out but I am not sure how to send this remote signal to the black box (KLS-205X).
This is an image of the remote kit I bought that hooks up to 12V battery and my winch.
It may be possible for an Arduino and a 433 MHz transmitter to replicate the keyfob signal, but the signal has to be captured and understood. I did a quick search, and it does not appear that anyone has hacked that particular remote, so you would have to do that yourself.
Here is a tutorial that gives a general procedure to decode many different types of remote sensors, and may be applicable.
Alternatively, you could have the Arduino electronically push the buttons on the remote.
Before I go back to re-sniff my RF device I thought I would post the code I am using to send the RF signal with the RF Link Transmitter - 434MHz (WRL-10534) and see if I am doing something wrong in the code.
This code results in no response. I know it is sending something but not making the winch go in. I am pretty sure I have the right series of 1/0 but I may not have the delays correct. So I am going to redo my rf-sniff, but any comments on the code is appreciated.
// Example code for OpenSprinkler RF switch
/* This is demo code for sending RF control signal to
Stanley Indoor Wireless Remote System
Creative Commons Attribution-ShareAlike 3.0 license
June 2012 @ Rayshobby.net
*/
#define RF_DATA_PIN 3
#define SHORT_DELAY 396
#define LONG_DELAY (3*SHORT_DELAY)
#define TOTAL_DELAY (4*SHORT_DELAY)
#define SYNC_DELAY (9*SHORT_DELAY)
void rf_send(unsigned char command) {
unsigned char k;
unsigned char first, second;
int d;
// send command (on/off)
first = 0b00010011;
for(k=0;k<8;k++) {
d = ((first>>(7-k)) & 1 ? LONG_DELAY : SHORT_DELAY);
digitalWrite(RF_DATA_PIN, HIGH);
delayMicroseconds(d);
digitalWrite(RF_DATA_PIN, LOW);
delayMicroseconds(TOTAL_DELAY - d);
}
Serial.println("first str ");
// send index string (which station)
second = 0b11001100;
for(k=0;k<8;k++) {
d = ((second>>(7-k)) & 1 ? LONG_DELAY : SHORT_DELAY);
digitalWrite(RF_DATA_PIN, HIGH);
delayMicroseconds(d);
digitalWrite(RF_DATA_PIN, LOW);
delayMicroseconds(TOTAL_DELAY - d);
}
Serial.println("seconsd str ");
// send command (out/in)
for(k=0;k<8;k++) {
d = ((command>>(7-k)) & 1 ? LONG_DELAY : SHORT_DELAY);
digitalWrite(RF_DATA_PIN, HIGH);
delayMicroseconds(d);
digitalWrite(RF_DATA_PIN, LOW);
delayMicroseconds(TOTAL_DELAY - d);
}
Serial.println("command\n");
delayMicroseconds(SYNC_DELAY);
}
void rf_winch_off() {
pinMode(RF_DATA_PIN, OUTPUT);
// send the same signal multiple times
// with sync delay
for(unsigned char i=0;i<10;i++) {
rf_send(0b00000000);
}
}
void rf_winch_out() {
pinMode(RF_DATA_PIN, OUTPUT);
// send the same signal multiple times
// with sync delay
for(unsigned char i=0;i<10;i++) {
rf_send(0b10000011);
}
}
void rf_winch_in() {
pinMode(RF_DATA_PIN, OUTPUT);
// send the same signal multiple times
// with sync delay
for(unsigned char i=0;i<10;i++) {
rf_send(0b10000000);
}
}
void setup() {
Serial.begin(9600);
}
void loop() {
rf_winch_in();
}
my rf_out looks like it is sending the correct signal. When I compare the samples of the correct one it is 1861 samples and the non-working is 1958. So I think that is within the range of error. Since Rayshobby said my samples didn't have to be exact. My rf_in does have a problem on the end and I think that is because it ends with zero and that goes into the pause at zero so it is getting dropped. Still trying to figure that out.
I took out the Serial and printing lines but that didn't seem to make any difference. So could Rayshobby be wrong and I need to have the signal be exact to the samples?
Yahoo! I got it! Thank you @jremington! Your direction and helpful guidance made a huge difference in solving this for me. Thought it might help someone to post my final code.
// Example code for winch RF switch
/* This code for sending RF control signal to
winch Wireless Remote System taken from ( and modified by MJ)
Creative Commons Attribution-ShareAlike 3.0 license
June 2012 @ Rayshobby.net
*/
#define RF_DATA_PIN 3
#define SHORT_DELAY 430
#define LONG_DELAY (3*SHORT_DELAY)
#define TOTAL_DELAY (4*SHORT_DELAY)
#define SYNC_DELAY (7*SHORT_DELAY)
unsigned long currentTime;
unsigned long startTime;
unsigned long durTime = 5000; // 5 sec, change to about of winch_in() time
unsigned long timerStart,
interval = 30000, // 30 sec, change to 3600000 for 1 hr
onTime = 5000; // 5 sec, change to 600000 for 10 min
const byte relayPin = 13; // onboard LED, change to your relay pin number
void rf_send(unsigned char command) {
unsigned char k;
unsigned char first, second;
int d;
// send command (on/off)
first = 0b00010011;
for(k=0;k<8;k++) {
d = ((first>>(7-k)) & 1 ? LONG_DELAY : SHORT_DELAY);
digitalWrite(RF_DATA_PIN, HIGH);
delayMicroseconds(d);
digitalWrite(RF_DATA_PIN, LOW);
delayMicroseconds(TOTAL_DELAY - d);
}
// send index string (which station)
second = 0b11001100;
for(k=0;k<8;k++) {
d = ((second>>(7-k)) & 1 ? LONG_DELAY : SHORT_DELAY);
digitalWrite(RF_DATA_PIN, HIGH);
delayMicroseconds(d);
digitalWrite(RF_DATA_PIN, LOW);
delayMicroseconds(TOTAL_DELAY - d);
}
// send command (out/in)
for(k=0;k<8;k++) {
d = ((command>>(7-k)) & 1 ? LONG_DELAY : SHORT_DELAY);
digitalWrite(RF_DATA_PIN, HIGH);
delayMicroseconds(d);
digitalWrite(RF_DATA_PIN, LOW);
delayMicroseconds(TOTAL_DELAY - d);
}
digitalWrite(RF_DATA_PIN, HIGH);
delayMicroseconds(SHORT_DELAY);
digitalWrite(RF_DATA_PIN, LOW);
delayMicroseconds(SHORT_DELAY);
delayMicroseconds(SYNC_DELAY);
}
void rf_winch_off() {
pinMode(RF_DATA_PIN, OUTPUT);
// send the same signal multiple times
// with sync delay
for(unsigned char i=0;i<10;i++) {
rf_send(0b00000000, 0);
}
}
void rf_winch_out() {
pinMode(RF_DATA_PIN, OUTPUT);
// send the same signal multiple times
// with sync delay
for(unsigned char i=0;i<10;i++) {
rf_send(0b10000011);
}
}
void rf_winch_in() {
pinMode(RF_DATA_PIN, OUTPUT);
// send the same signal multiple times
// with sync delay
for(unsigned char i=0;i<10;i++) {
rf_send(0b10001100);
}
}
void setup() {
Serial.begin(44100);
startTime = millis();
pinMode(relayPin,OUTPUT);
}
void loop()
{
currentTime = millis();
//digitalWrite(relayPin, millis() - timerStart < onTime);
if (currentTime - timerStart < durTime) {
digitalWrite(relayPin, 1);
rf_winch_in();
} else digitalWrite(relayPin, 0);
if(currentTime - timerStart > interval)
{
timerStart += interval;
}
}