Go Down

Topic: DAC that can output more than 5v (Read 5164 times) previous topic - next topic

OldSteve

So you still fail miserably to explain why you think the usual signal that goes to a servo is PPM.  Really very pathetic!
Does it matter exactly what it's called? It could be called Swiss cheese for all I care. More important is the matter of how to make use of it in David's project. The PWM/PPM argument is just muddying the waters.

As long as he's aware that pulse-length measurement is needed to measure the pulses, then either filtered PWM output or serial to a DAC, followed by an op-amp for level conversion, nothing else really matters.

Perhaps the s**tfight is better carried on in PMs?
Please do not PM me for help. I am not a personal consultant.
And others will benefit as well if you post your question publicly on the forums.

Archibald

#46
Nov 09, 2015, 10:38 pm Last Edit: Nov 11, 2015, 01:45 pm by Archibald
Does it matter exactly what it's called? It could be called Swiss cheese for all I care. More important is the matter of how to make use of it in David's project. The PWM/PPM argument is just muddying the waters.

As long as he's aware that pulse-length measurement is needed to measure the pulses, then either filtered PWM output or serial to a DAC, followed by an op-amp for level conversion, nothing else really matters.
Yes I fully agree.

Let's agree that the outputs from the radio control receiver have pulse widths varying between 1ms and 2ms that convey the information.

As I see things there are at least three options:

1) Filter the signals that would have gone to each servo. As the frame rate is only roughly 50Hz, any filter design may slow the response time too much (as mentioned in the original post).  The frame rate is unlikely to be constant and this will affect a filtered signal but only very slightly.

2) Get an Arduino to measure the pulse widths of both servo outputs from the receiver. Then either use two digital-to-analogue converters (DACs) or two PWM outputs from the Arduino. If using DACs, the delay involved should be insignificant.  If using PWM outputs, they will need to be filtered, but as the frequency is about 490Hz even a simple resistor-capacitor network may well be adequate.  My understanding is that the pulses from the receiver's servo outputs do not occur at the same time so pulseIn() could be used.

3) Design electronics to convert the pulse widths to a control voltage, possibly utilising available servo motor control integrated circuits or utilising PCBs extracted from servos.

While also recognising that there will be a need for an amplifier, is that a reasonable summary?

OldSteve

Yes I fully agree.

Let's agree that the outputs from the radio control receiver have pulse widths varying between 1ms and 2ms that convey the information.

As I see things there are at least three options:

1) Filter the signals that would have gone to each servo. As the frame rate is only roughly 50Hz, any filter design may slow the response time too much (as mentioned in the original post).  The frame rate is unlikely to be constant and this will affect a filtered signal but only very slightly.

2) Get an Arduino to measure the pulse widths of both servo outputs from the receiver. Then either use two digital-to-analogue converters (DACs) or two PWM outputs from the Arduino. If using DACs, the delay involved should be insignificant.  If using PWM outputs, they will need to be filtered, but as the frequency is about 490Hz even a simple resistor-capacitor network may well be adequate.  My understanding is that the pulses from the receiver's servo outputs do not occur at the same time so pulseln() could be used.

3) Design electronics to convert the pulse widths to a control voltage, possibly utilising available servo motor control integrated circuits or utilising PCBs extracted from servos.

While also recognising that there will be a need for an amplifier, is that a reasonable summary?
More or less. Except that regarding number 2, fast PWM could be used to speed response time and allow a smaller filter cap to be used. The fast PWM could be done manually, or with a library such as the 'PWM Frequency Library'. It has a top frequency of 2MHz, so good resolution could still be obtained even as fast as 50kHz I would think. (I've looked at the waveform on a 'scope even at 490kHz and it looked pretty good.)

Also David said in post #35 that the pulses are in phase, so unless he's mistaken either DIY pulse measurement would be needed, or possibly the 'PulseInZero' library.

All done. :D
Please do not PM me for help. I am not a personal consultant.
And others will benefit as well if you post your question publicly on the forums.

David82

#48
Nov 18, 2015, 04:19 am Last Edit: Nov 18, 2015, 06:07 am by David82
Finally got it done!

I used an arduino UNO with an op amp circuit (circuit B). I used 104 and 102 variable resistors (in place of all resistors) though, and only one "F105J 100MEFI" capacitor, per channel.

The arduino converts the thin pulses from each RC receiver channel to the more typical 50% duty-cycle PWM. That allows for a faster-reacting capacitor in the op-amp circuit (since it's a lot easier to smooth a 50% duty-cycle circuit vs. what was originally coming out of the receiver).
Code: [Select]

int pin_x = 7;
int pin_y = 4;
int pin_pwm_out_x = 9;
int pin_pwm_out_y = 10;
double result_x = 0.0;
double result_y = 0.0;
double ppm_lower_limit = 1090.0;
double pwm_max_deviation_from_center = 26; // increase this if there is not enough voltage travel
double thumb_stick_travel_percent = 0.0;
double half_thumb_stick_travel = 400.0;
unsigned long duration_x;
unsigned long duration_y;

void setup(){
 Serial.begin(9600);
 pinMode(pin_x, INPUT);
 pinMode(pin_y, INPUT);
 pinMode(pin_pwm_out_x, OUTPUT);
 pinMode(pin_pwm_out_y, OUTPUT);
}

void loop(){
 // duration values are usually between 1090 and 1890
 duration_x = pulseIn(pin_x, HIGH);
 duration_y = pulseIn(pin_y, HIGH);
 
 // use these if you want the full 0-255 range
 // result_x = (duration_x - ppm_lower_limit) / 3.14;
 // result_y = (duration_y - ppm_lower_limit) / 3.14;

 // AXIS 1
 thumb_stick_travel_percent = duration_x - ppm_lower_limit;
 if (thumb_stick_travel_percent >= half_thumb_stick_travel){
    thumb_stick_travel_percent = (thumb_stick_travel_percent - half_thumb_stick_travel) / half_thumb_stick_travel;
    result_x = 127.0 - (thumb_stick_travel_percent * pwm_max_deviation_from_center);
 } else {
    thumb_stick_travel_percent = (half_thumb_stick_travel - thumb_stick_travel_percent) / half_thumb_stick_travel;
    result_x = 127.0 + (thumb_stick_travel_percent * pwm_max_deviation_from_center);
 }

 // AXIS 2
 thumb_stick_travel_percent = duration_y - ppm_lower_limit;
 if (thumb_stick_travel_percent >= half_thumb_stick_travel){
    thumb_stick_travel_percent = (thumb_stick_travel_percent - half_thumb_stick_travel) / half_thumb_stick_travel;
    result_y = 127.0 - (thumb_stick_travel_percent * pwm_max_deviation_from_center);
 } else {
    thumb_stick_travel_percent = (half_thumb_stick_travel - thumb_stick_travel_percent) / half_thumb_stick_travel;
    result_y = 127.0 + (thumb_stick_travel_percent * pwm_max_deviation_from_center);
 }
 
 analogWrite(pin_pwm_out_x, result_x);
 analogWrite(pin_pwm_out_y, result_y);
 
 // debugging
//  Serial.print(duration_x);
//  Serial.print(" = ");
//  Serial.print(result_x);
//  Serial.print("\t");
//  Serial.print(duration_y);
//  Serial.print(" = ");
//  Serial.println(result_y);
}







OldSteve

Glad to hear it.

But, after 365 posts on these forums, you should be well aware that you can't post your code inline and that it must be between code tags.
Please do not PM me for help. I am not a personal consultant.
And others will benefit as well if you post your question publicly on the forums.

David82

#50
Nov 18, 2015, 06:05 am Last Edit: Nov 18, 2015, 06:08 am by David82
yea, I was looking for the code tag button but it seems to be missing, or has an unusual icon... I just guessed on what the code tag was and it seems to work.

OldSteve

yea, I was looking for the code tag button but it seems to be missing, or has an unusual icon... I just guessed on what the code tag was and it seems to work.
Thanks David, that looks healthier. I guess you used the word "code" between square brackets before the code, then "/code" between square brackets after it. (Without the "").
That's handy if using the "Quick Reply" window, since it doesn't have the code tags </> option.
(For the </> code tags option, you need to click on the "Reply" button, rather than use the "Quick Reply" window.)
Please do not PM me for help. I am not a personal consultant.
And others will benefit as well if you post your question publicly on the forums.

Grumpy_Mike

My quick reply has the </> icon top left.

OldSteve

My quick reply has the </> icon top left.
Really? That's odd, (or mine is).
I have no toolbar at all on the "Quick Reply" window.
(See attached Screenshot)
Please do not PM me for help. I am not a personal consultant.
And others will benefit as well if you post your question publicly on the forums.

David82

I have a question as to what relay can be used to remotely control a 24V 30A load (the lawn mower blade motor) in this thread if you know the answer http://forum.arduino.cc/index.php?topic=360275

Go Up