Servo Tester - Read Receiver Pulses with Arduino

Projects that are not for RC, but are cool and worthy of development.
User avatar
jhsa
Posts: 19390
Joined: Tue Dec 27, 2011 5:13 pm
Country: Germany

Servo Tester - Read Receiver Pulses with Arduino

Post by jhsa » Tue Feb 26, 2013 9:53 pm

Hi guys..
I've built my arduino and a kind of LCD shield for it. It's a 16x2 LCD.
I will use it to learn but would also like to be able to make something useful with it at the same time.
Something that after testing I could obviously buy all the components, build it, and put it in a case.
I thought of a Servo tester, servo cycler, that could also read the pulses from a couple of receiver channels at the same time and display the data on the LCD. It could also read the pack voltage.

I've searched the web and found a couple of projects, but they were not made with arduino, or wouldn't do all I wanted..

If you know of a project like this one please point me to it.. Thank you.. I think this is a nice useful RC project to build..

João
My er9x/Ersky9x/eepskye Video Tutorials
https://www.youtube.com/playlist?list=PL5uJhoD7sAKidZmkhMpYpp_qcuIqJXhb9

Donate to Er9x/Ersky9x:
https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=YHX43JR3J7XGW


User avatar
jhsa
Posts: 19390
Joined: Tue Dec 27, 2011 5:13 pm
Country: Germany

Re: Servo Tester - Read Receiver Pulses with Arduino

Post by jhsa » Wed Feb 27, 2013 1:30 am

Ok I found this project here.. It looks good. It has a lot of options..
My question is:
would it be possible to adapt this to arduino? or even use an atmega 8 instead? (only because I have a couple laying around ;) )

http://www.ejberg.dk/servotst2/index.html

Thanks,
João
My er9x/Ersky9x/eepskye Video Tutorials
https://www.youtube.com/playlist?list=PL5uJhoD7sAKidZmkhMpYpp_qcuIqJXhb9

Donate to Er9x/Ersky9x:
https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=YHX43JR3J7XGW

User avatar
rperkins
Posts: 1422
Joined: Sun Jan 08, 2012 12:51 pm
Country: -

Re: Servo Tester - Read Receiver Pulses with Arduino

Post by rperkins » Wed Feb 27, 2013 1:33 am

While not exactly what you are looking for, this might help.
A code fragment to read a PPM sum signal using interrupts. I use it in my IrModule.

http://diydrones.com/profiles/blogs/705 ... Post:39393

User avatar
rperkins
Posts: 1422
Joined: Sun Jan 08, 2012 12:51 pm
Country: -

Re: Servo Tester - Read Receiver Pulses with Arduino

Post by rperkins » Wed Feb 27, 2013 1:42 am

His source file throws up a 403 forbidden. The license is restricted allso. The schematic showed an avr @ 10mhz. You could probably add something to your boards.txt in arduino to be able to utilize the ide with that avr/clock speed. Not sure how usable the assembly based source would be within the arduino ide. Also saw something about the serial interfa e not being complete. Maybe it was complete on v1. In spite of all this it is worth pursuing. I'd shoot the designer an email.

User avatar
jhsa
Posts: 19390
Joined: Tue Dec 27, 2011 5:13 pm
Country: Germany

Re: Servo Tester - Read Receiver Pulses with Arduino

Post by jhsa » Wed Feb 27, 2013 2:28 am

I could download the source, no problem. here it is..
It would be nice if this could be ported to the arduino.. Also could this be adapted to run at 16Mhz, which is the arduino speed?

Sorry, I don't understand much about this.. still on the blinking a LED stage.. And still having problems with it ;)

João
Attachments
servotst2.zip
(40.85 KiB) Downloaded 274 times
My er9x/Ersky9x/eepskye Video Tutorials
https://www.youtube.com/playlist?list=PL5uJhoD7sAKidZmkhMpYpp_qcuIqJXhb9

Donate to Er9x/Ersky9x:
https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=YHX43JR3J7XGW


User avatar
rperkins
Posts: 1422
Joined: Sun Jan 08, 2012 12:51 pm
Country: -

Re: Servo Tester - Read Receiver Pulses with Arduino

Post by rperkins » Wed Feb 27, 2013 3:01 am

Hmm. It failed at work with tablet thru verizon. I ssh'ed home and wgetted from there. Still no go. Maybe I copied the url wrong ?
Anyway
I think arduino can be manipulated to compile assembly, but it's not very friendly to modify. It's beyond my comprehension.

User avatar
jhsa
Posts: 19390
Joined: Tue Dec 27, 2011 5:13 pm
Country: Germany

Re: Servo Tester - Read Receiver Pulses with Arduino

Post by jhsa » Wed Feb 27, 2013 10:32 am

I sent him a email.. let's see if he answers.. ;)
My er9x/Ersky9x/eepskye Video Tutorials
https://www.youtube.com/playlist?list=PL5uJhoD7sAKidZmkhMpYpp_qcuIqJXhb9

Donate to Er9x/Ersky9x:
https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=YHX43JR3J7XGW

ReSt
Posts: 1549
Joined: Tue Dec 27, 2011 11:34 pm
Country: -

Re: Servo Tester - Read Receiver Pulses with Arduino

Post by ReSt » Wed Feb 27, 2013 12:54 pm

At least it assemles without problem when loaded into AVRStudio

Reinhard

User avatar
jhsa
Posts: 19390
Joined: Tue Dec 27, 2011 5:13 pm
Country: Germany

Re: Servo Tester - Read Receiver Pulses with Arduino

Post by jhsa » Wed Feb 27, 2013 3:22 pm

So, does that mean I can use any other atmega?
Thanks
My er9x/Ersky9x/eepskye Video Tutorials
https://www.youtube.com/playlist?list=PL5uJhoD7sAKidZmkhMpYpp_qcuIqJXhb9

Donate to Er9x/Ersky9x:
https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=YHX43JR3J7XGW

User avatar
rperkins
Posts: 1422
Joined: Sun Jan 08, 2012 12:51 pm
Country: -

Re: Servo Tester - Read Receiver Pulses with Arduino

Post by rperkins » Wed Feb 27, 2013 4:13 pm

Dont know for sure but here would be some things to take into consideration.
This would be a good project to learn some assembly :)

I see where he calls out a 10 mhz crystal

Code: Select all

lcd.inc:        nop                             ;500 ns delay (@ 10 MHz xtal)
lcd.inc:        nop                             ;500 ns delay (@ 10 MHz xtal)
util.inc:        push    w1                      ;Only valid for 10 MHz xtal
several timers. I know when trying to port a simple library to an M8 the timers had different cababilities and were defined differently

and a lot of interrupt routines

Code: Select all

;**** Interrupt routines

EXT_INT0:   ; IRQ0
        call    RotaryChange_int
        reti

EXT_INT1:   ; IRQ1
        call    RotaryChange_int
        reti

TIM2_COMP:  ; Timer2 Output Compare Match
        call    Timer_CompareMatch_int
        reti

TIM1_CAPT:  ; Timer1 Input Capture Handler
        call    Pulse_InputCapture_int
        reti


TIM1_OVF:   ; Timer1 Overflow Handler
        call    Pulse_Overflow_int
        reti


ADC_COMP:   ; A/D Converter Conversion Complete
        call    ADC_Complete_int
        reti

ReSt
Posts: 1549
Joined: Tue Dec 27, 2011 11:34 pm
Country: -

Re: Servo Tester - Read Receiver Pulses with Arduino

Post by ReSt » Wed Feb 27, 2013 4:19 pm

I tried with ATMega328 but it will probably work with other types also. (ATMega48, 88, 168, 328 share the same manual, so should be no big differenc besides flash and eeprom size. But IIRC there are at least, differences in the fuse settings.)
Just tried for ATMega8 and it also assembles without error. May be, but don't know, if some registers or functions are different, but, I simply would try it.

Just saw last post, yes timers may be different

Reinhard

User avatar
rperkins
Posts: 1422
Joined: Sun Jan 08, 2012 12:51 pm
Country: -

Re: Servo Tester - Read Receiver Pulses with Arduino

Post by rperkins » Wed Feb 27, 2013 4:27 pm

but since it compiled ( I'm assuming aseembles =compiles) he may be in good shape. The project I was working on wouldnt even compile due to different definitions of the timer registers. There is still the 10mhz issue though

User avatar
jhsa
Posts: 19390
Joined: Tue Dec 27, 2011 5:13 pm
Country: Germany

Re: Servo Tester - Read Receiver Pulses with Arduino

Post by jhsa » Wed Feb 27, 2013 6:08 pm

could we change it to 12 or even 16Mhz? Sorry guys this was the only project I found that would do all I wanted. I think he only uses 10Mhz because the CPU can handle it at lower voltage.
My er9x/Ersky9x/eepskye Video Tutorials
https://www.youtube.com/playlist?list=PL5uJhoD7sAKidZmkhMpYpp_qcuIqJXhb9

Donate to Er9x/Ersky9x:
https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=YHX43JR3J7XGW

User avatar
hart
Posts: 94
Joined: Thu Feb 07, 2013 11:38 pm
Country: United Kingdom
Location: Belfast

Re: Servo Tester - Read Receiver Pulses with Arduino

Post by hart » Wed Feb 27, 2013 6:22 pm

I got my Arduino Uno to read pulses from my RX channel 8 using pulseIn() and detct the difference between on/off on my gear switch. Not sure what that means in terms of accuracy but given the number of Arduino based flight controllers, I suspect it is a good start :)

User avatar
rperkins
Posts: 1422
Joined: Sun Jan 08, 2012 12:51 pm
Country: -

Re: Servo Tester - Read Receiver Pulses with Arduino

Post by rperkins » Wed Feb 27, 2013 6:31 pm

my guess is that it would work with a different crystal but that the timers may have to be reconfigured. being that it is written in assembly, that's all I can say. Maybe you could get a 10mhz crystal and put that in your arduino ??

User avatar
jhsa
Posts: 19390
Joined: Tue Dec 27, 2011 5:13 pm
Country: Germany

Re: Servo Tester - Read Receiver Pulses with Arduino

Post by jhsa » Wed Feb 27, 2013 6:51 pm

if I have to get a XTAL then, or I could just as well get another atmega.. Or if it works with the atmega8 just get the XTAL.
This is a project to install inside a nice case and use it.. We could cycle new servos with it..

I think he mentions something about waiting for the atmega168 that was coming out at the time..

João
My er9x/Ersky9x/eepskye Video Tutorials
https://www.youtube.com/playlist?list=PL5uJhoD7sAKidZmkhMpYpp_qcuIqJXhb9

Donate to Er9x/Ersky9x:
https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=YHX43JR3J7XGW

User avatar
jhsa
Posts: 19390
Joined: Tue Dec 27, 2011 5:13 pm
Country: Germany

Re: Servo Tester - Read Receiver Pulses with Arduino

Post by jhsa » Wed Feb 27, 2013 6:53 pm

hart wrote:I got my Arduino Uno to read pulses from my RX channel 8 using pulseIn() and detct the difference between on/off on my gear switch. Not sure what that means in terms of accuracy but given the number of Arduino based flight controllers, I suspect it is a good start :)
Most of the posts and sites I've read about this say to not use "pulsein" because it is not accurate.
My er9x/Ersky9x/eepskye Video Tutorials
https://www.youtube.com/playlist?list=PL5uJhoD7sAKidZmkhMpYpp_qcuIqJXhb9

Donate to Er9x/Ersky9x:
https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=YHX43JR3J7XGW

User avatar
MikeB
9x Developer
Posts: 17274
Joined: Tue Dec 27, 2011 1:24 pm
Country: -
Location: Poole, Dorset, UK

Re: Servo Tester - Read Receiver Pulses with Arduino

Post by MikeB » Wed Feb 27, 2013 7:08 pm

What frequency crystal is on your board? The 'M328 will go up to 20 MHz, and there is an option to divide the clock by 2 to give 10 MHz.

Mike.
erskyTx/er9x developer
The difficult we do immediately,
The impossible takes a little longer!

User avatar
jhsa
Posts: 19390
Joined: Tue Dec 27, 2011 5:13 pm
Country: Germany

Re: Servo Tester - Read Receiver Pulses with Arduino

Post by jhsa » Wed Feb 27, 2013 7:11 pm

I have a 16Mhz Crystal.. I built it following the arduino UNO schematic.. I just didn't build the USB to serial converter as I have an FTDI.
My er9x/Ersky9x/eepskye Video Tutorials
https://www.youtube.com/playlist?list=PL5uJhoD7sAKidZmkhMpYpp_qcuIqJXhb9

Donate to Er9x/Ersky9x:
https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=YHX43JR3J7XGW

User avatar
jhsa
Posts: 19390
Joined: Tue Dec 27, 2011 5:13 pm
Country: Germany

Re: Servo Tester - Read Receiver Pulses with Arduino

Post by jhsa » Wed Feb 27, 2013 7:15 pm

but that is not a problem.. I've decided now that I will build it to be permanent.. I just thought I could test it before with the arduino..

João
My er9x/Ersky9x/eepskye Video Tutorials
https://www.youtube.com/playlist?list=PL5uJhoD7sAKidZmkhMpYpp_qcuIqJXhb9

Donate to Er9x/Ersky9x:
https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=YHX43JR3J7XGW

User avatar
MikeB
9x Developer
Posts: 17274
Joined: Tue Dec 27, 2011 1:24 pm
Country: -
Location: Poole, Dorset, UK

Re: Servo Tester - Read Receiver Pulses with Arduino

Post by MikeB » Wed Feb 27, 2013 9:06 pm

I built something simpler 10 years ago using a Microchip PIC and 2 7-segment displays to show 0-99. The main feature I wanted was a pot so I could set the servo pulse and use this to set up servos without needing the Tx and Rx connected. It did also measure the servo pulse from a receiver. All written in PIC assembly language!
I recommend including a POT to allow use to set up servos, it is very useful for setting the centre and throws mechanically.

Mike.
erskyTx/er9x developer
The difficult we do immediately,
The impossible takes a little longer!

User avatar
Kilrah
Posts: 10739
Joined: Sat Feb 18, 2012 6:56 pm
Country: Switzerland

Re: Servo Tester - Read Receiver Pulses with Arduino

Post by Kilrah » Wed Feb 27, 2013 9:41 pm

Ah, the good times of PIC assembly, I've gone through that too! Have to say their instruction set was very convenient to use!

But the first pulse width display I built used 4 LED 7-segment displays... entirely driven by standard discrete logic chips :)

User avatar
gohsthb
Posts: 1412
Joined: Wed Dec 28, 2011 2:32 pm
Country: -
Location: Naperville, IL

Re: Servo Tester - Read Receiver Pulses with Arduino

Post by gohsthb » Wed Feb 27, 2013 9:54 pm

I don't know how much help this will be. I am using an interrupt in an Attiny25 to read a receiver ppm input.

Code: Select all

// external interrupt on the INT0 pin
ISR(INT0_vect) {
	if(PINB & (1<<ppmInPin)) {  // pin is high, start of ppm pulse
		TCCR1 = 0x08; // start timer1; CK/128, timer input clock
		MCUCR = 0x02; // interrupt on falling edge
	} else {
		// it is now the end of the pulse
		TCCR1 = 0; // stop the clock
		if(TCNT1 > 50) { // check if a real pulse, not a transient
			if(!(TIFR & (1<<TOV1))) { // make sure the timer didn't overflow
				ppmin = TCNT1; // record the new value
				ppmLastUpdate = millis();
				neverPPM = false;
			} else {
				TIFR |= (1<<TOV1); // clear the flag if set
			}
		}
		TCNT1 = 0; // clear counter
		GTCCR = 0x01; // clear prescaler
		MCUCR = 0x03; // interrupt on rising edge
	}
}
The external interrupt (int0 pin) is initially set to trigger on a rising edge. The first time through starts the timer, and switches the interrupt to the falling edge. When the falling edge comes, the interrupt stops the clock, checks if it was a valid pulse, if so copies the value to the ppmin variable. And finally resets the timer, and interrupt edge. Using the internal oscillator I have a resolution of 16us. Of course my timer is only 8 bits.
-Gohst

Doing something similar with an Arduino you can get 62.5 nS resolution. Just use 16-bit timer1, and set it's prescaler to 1.

User avatar
jhsa
Posts: 19390
Joined: Tue Dec 27, 2011 5:13 pm
Country: Germany

Re: Servo Tester - Read Receiver Pulses with Arduino

Post by jhsa » Wed Feb 27, 2013 10:48 pm

Ok, guys, thank you very much for all your inputs..
I just went shopping and didn't see the latest posts.. was very busy buying chips.. and othe relectronic stuff that I need.
Didin't buy the encoder cos at reichelt they wanted about €18 for one without push button. so, no.. then I thought of building the servo tester 1, as I don't need the tachometer, and battery voltage/current features.. What I need, the version 1 can do which is, read receiver pulses with an without passing the signal to the servo, sweep (cycle) the servo. these 2 features were the main reason I wanted to build it anyway..
But as we never know the future, I bought an Atmega 16 also ;)
also got some 10Mhz Xtal

Bought an ATtiny 2313 for the servo tester 1 and a 16x1 LCD but I have some 16x2 LCDs also

Got a couple ATtiny 85 because they look cute :D No, but they are excellent for little projects, and they are cheap.. I can think of a few RC applications for them. Maybe future projects?? ;) Glow plug drivers, switches, etc.. :)


Gohst, you are reading the receiver channels with the Tiny and then sending them to the computer, right?..
It's a shame that I can't program yet.. but I learn fast. I'm on my second blinking LED at the moment :D

I would like to build something like in that servo tester project, with an LCD. forget the encoder as it gets too expensive :)
Now shall we stay with it or maybe develop something 9x gang style? :mrgreen: :mrgreen:

Thanks

João
My er9x/Ersky9x/eepskye Video Tutorials
https://www.youtube.com/playlist?list=PL5uJhoD7sAKidZmkhMpYpp_qcuIqJXhb9

Donate to Er9x/Ersky9x:
https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=YHX43JR3J7XGW

User avatar
gohsthb
Posts: 1412
Joined: Wed Dec 28, 2011 2:32 pm
Country: -
Location: Naperville, IL

Re: Servo Tester - Read Receiver Pulses with Arduino

Post by gohsthb » Wed Feb 27, 2013 11:00 pm

Actually that is part of the program for my helicopter lights. It has 3 modes, that is why I read the receiver channel. Off, scale lights only, and full night illumination. It is a scale Hughes 500. So no output to the computer. Also it will detect a signal loss (no ppm signal) and flash all of the lights.
-Gohst

User avatar
MikeB
9x Developer
Posts: 17274
Joined: Tue Dec 27, 2011 1:24 pm
Country: -
Location: Poole, Dorset, UK

Re: Servo Tester - Read Receiver Pulses with Arduino

Post by MikeB » Wed Feb 27, 2013 11:06 pm

Link to another of my past projects: http://www.giantshark.co.uk/forum/viewt ... lit=#p6970.

Mike.
erskyTx/er9x developer
The difficult we do immediately,
The impossible takes a little longer!

User avatar
jhsa
Posts: 19390
Joined: Tue Dec 27, 2011 5:13 pm
Country: Germany

Re: Servo Tester - Read Receiver Pulses with Arduino

Post by jhsa » Wed Feb 27, 2013 11:34 pm

MikeB wrote:Link to another of my past projects: http://www.giantshark.co.uk/forum/viewt ... lit=#p6970.

Mike.
Very nice project Mike.. Hmm, that gives me some ideas.. ;) :P
My er9x/Ersky9x/eepskye Video Tutorials
https://www.youtube.com/playlist?list=PL5uJhoD7sAKidZmkhMpYpp_qcuIqJXhb9

Donate to Er9x/Ersky9x:
https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=YHX43JR3J7XGW

User avatar
jhsa
Posts: 19390
Joined: Tue Dec 27, 2011 5:13 pm
Country: Germany

Re: Servo Tester - Read Receiver Pulses with Arduino

Post by jhsa » Wed Feb 27, 2013 11:37 pm

gohsthb wrote:Actually that is part of the program for my helicopter lights. It has 3 modes, that is why I read the receiver channel. Off, scale lights only, and full night illumination. It is a scale Hughes 500. So no output to the computer. Also it will detect a signal loss (no ppm signal) and flash all of the lights.
-Gohst
It looks like the construction ot that kit has some quality.. And not bad for the price.. not at all..
My er9x/Ersky9x/eepskye Video Tutorials
https://www.youtube.com/playlist?list=PL5uJhoD7sAKidZmkhMpYpp_qcuIqJXhb9

Donate to Er9x/Ersky9x:
https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=YHX43JR3J7XGW

User avatar
hart
Posts: 94
Joined: Thu Feb 07, 2013 11:38 pm
Country: United Kingdom
Location: Belfast

Re: Servo Tester - Read Receiver Pulses with Arduino

Post by hart » Fri Mar 01, 2013 3:09 pm

João, with the servo tester idea - is the pulseIn Arduino method any use to you? I was able to detect values 1400-1900 on my gear channel, for example, using the attiny45 - not sure I understand the complexity of this yet :)

User avatar
jhsa
Posts: 19390
Joined: Tue Dec 27, 2011 5:13 pm
Country: Germany

Re: Servo Tester - Read Receiver Pulses with Arduino

Post by jhsa » Fri Mar 01, 2013 3:13 pm

I will try to build the servo tester version 1 from the link I posted above.. the problem is that the code is in assembler, so not of much use for me I guess.. I also have all the parts now for the version 2 but the price reichelt wanted for the encoder was prohibitive..

João

It seems that for some reason the pulsein is not very precise? and if you try to read more than 2 channels it won't work well??
At least that's what I've read..

João
My er9x/Ersky9x/eepskye Video Tutorials
https://www.youtube.com/playlist?list=PL5uJhoD7sAKidZmkhMpYpp_qcuIqJXhb9

Donate to Er9x/Ersky9x:
https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=YHX43JR3J7XGW


Post Reply

Return to “Other Electronic Projects”