PWM to Serial converter

Hi all ,

I have camera Sony FBC , which accept commands as "Serial data RS232 " . In the other side I have Remote control Frsky which send command as " PWM " .

I want to use Arduino to receive "PWM" signal from the RC , And convert it to "Serial data RS232 "

For Example :


if ( PWM == 1100 ) low { Serial output = (8x 01 04 3E 02 FF); } else if ( PWM == 1800 ) high { Serial output = (8x 01 04 00 02 FF);

}


I hope the Idea is clear .

I appreciate any helpز

Regards . Jone

You can use the pulseIn() function to get the pulse width of the servo signal. Check the Reference.

For multiple channels received on a single line you need a RC receiver library, to split the received pulses again into multiple channels.

DrDiettrich: For multiple channels received on a single line you need a RC receiver library, to split the received pulses again into multiple channels.

Could you give me any link for the library ?

Is it essential to us the "Remote control Frsky" or would a wireless system more suited to the Arduino be a better alternative?

And if you do want to use the Frsky please post a link to its datasheet or user manual.

...R

I did some code will make the Idea clear more .


int PWM_Input_Pin = 3;

int pwm_value;

String zoomIn; // declare serial command for zoom in String zoomOut; // declare serial command for zoom out String StopZoom; // declare serial command for zoom stop

void setup() {

pinMode(PWM_Input_Pin , INPUT);

zoomIn = "8x 01 04 3E 02 FF"; zoomOut = "8x 01 04 00 02 FF"; StopZoom = "8x 01 01 00 02 FF";

Serial.begin(9600);

}

void loop() {

pwm_value = pulseIn(PWM_Input_Pin ,HIGH);

pwm_value = map(pwm_value, 0, 1023, 1000, 2000); // I don't know if this right ??

if(Serial.available()== 0) { Serial.println(pwm_value);

if ( pwm_value == 1000) {

Serial.println(zoomIn);

}else if ( pwm_value == 1500){

Serial.println(StopZoom );

}else if ( pwm_value == 2000){

Serial.println(zoomOut); } }

delay(1000); }


the PWM is connected to Pin (3) the PWM range ( 1000 - 2000 ) 20ms

Any help to correcr the code . I am not sure about the map function.

Regards

I don't thinnk that you even need the map function. If you are measuring a servo signal (receiver output), pulseIn() will return a value between 1000 and 2000 microseconds (nominal.

What is the Serial.available doing?