Servo Tester - Read Receiver Pulses with Arduino

Projects that are not for RC, but are cool and worthy of development.
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 » Fri Mar 01, 2013 8:18 pm

Yes. When i tried to read 4 ch from 9x into arduino using pulsein, not very good. The key is to use an interrupt driven routine like the diydrone link i posted earlier. Btw, the asembly code you are considering is also interrupt driven :) I agree the assembly code would be a lot harder for a mere mortal like me to adapt and utilize. Plus i prefer a more open license. Even to download the code was tricky. Could get it thru a browser , but not on android or with wget. Must be restricting based on user agent. It's a nice project but i'd keep looking.


User avatar
jhsa
Posts: 18956
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 11:14 pm

Ok, I got the parts to build the servo tester 1 from the link I posted above.. Here is the schematic.. I got a couple doubts though..
As you can see the reset pin is directly connected to VCC.. Can that be? normally on this kind of chip we use a 10K resistor between reset and VCC.. And also to program, if the programmer try to pull the reset pin low, which I have thew feeling that it will.. BAM.. or am I wrong?

The author also didn't mention what fuses should be set.. just provides a hex file and an eeprom file that has also to be flashed onto the chip..

Any ideas? I'm really worried about the reset being directly connected to VCC as I never seen it before

Thanks

João
Attachments
servotst.gif
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 » Fri Mar 01, 2013 11:22 pm

I'd duplicate the arduino reset circuit. Maybe he programmed his chip out of circuit.

For the fuse i use 'avr burn o mat' to help me get the right values. That and the datasheet.

User avatar
jhsa
Posts: 18956
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 11:26 pm

thanks for your reply.. I wouldn't know how to look for the right fuses.. not yet :(

So, you mean put a 10K resistor on the reset line anyway? the datasheet sai that the pin already has a pullup resistor.. don't know if it is active or not.. Or if I'm saying a big pile of c.. errr nonsense here :D

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: 18956
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 11:31 pm

This a quote from this site..
The circuit is so simple, that I didn't even bothered to make a dedicated PCB for it. Just mock it up on whatever you may have nearby. But for your own sake, make sure you put the AVR in a socket in case of problems or future software revisions.
So, I think you are right, he programs the chip outside the servo tester..
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 11:57 pm

Ah, yes I did see something like that too. Are you considering assembly or direct c?

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 » Sat Mar 02, 2013 1:29 am

http://arduino.cc/en/Main/Standalone

This is the reset circuit i've used on my projects.

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

Re: Servo Tester - Read Receiver Pulses with Arduino

Post by jhsa » Sat Mar 02, 2013 1:57 am

Yeap, that's what I always do, therefore I found strange the reset pin connected directly to VCC..
I've been designing a strip board layout and included the 10K resistor between the reset pin and VCC, like this I can program the chip without removing it from the board. Now, the only thing worrying me are the fuses.. I sent him another email asking about it.. hopefully he will reply.

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 » Sat Mar 02, 2013 2:11 am

For the fuses I normally read the fuses as hex and write them to files. Then i view the files to see what i got. Sometimes i plug those values into 'avr -burn -o-mat' as a starting point, sometimes just use the 'burn-o-mat' to read them. Then tweak the settings and burn it back I've seen mention of 'fuse mask' but havent quite figured that out. Do kknow '0' is programmed when talking about fuses.
Usually (this is from memory)
1 set the oscilllator settings. Ext crystal (not ext osc)- full scale output
2. Determine if i want brown out. Not usually
3. Max start up delay
4. No bootloader.

The main thing is the oscillator. When i get it wrong , most of the time using '-B 1000' on avrdude with usbasp programmer allows me to reprogram fuses. Cant use usbasp that generates 'SCK WARNING' with '-B' option.

Hope this helps. I've only made 2 protoboard devices and messed with the fuses on the usbasp boards

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

Re: Servo Tester - Read Receiver Pulses with Arduino

Post by jhsa » Sat Mar 02, 2013 2:30 am

I will wait for the guy's answer.. Maybe I don't have to change the fuses at all.. well, I guess I could just flash the hex and eeprom and see what happens. The worse that could happen is the thing not working as it should or not working at all, but I don't think I would brick the chip..

Thanks for your help

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 » Sat Mar 02, 2013 6:11 pm

If you google for "avr fuse calculator" there is a nice website that comes up. Engbedded I think? It will even give you the -U option to add to avrdude.
-Gohst

Sent from my LG-P999 using Tapatalk 2

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

Re: Servo Tester - Read Receiver Pulses with Arduino

Post by jhsa » Sat Mar 02, 2013 6:31 pm

Thanks, Gohst.. I will definitely check that as I want to learn how to calculate fuses..

Meanwhile The owner of the servo tester project I linked before answered my mail and did let me know about the fuses.. He also confirmed that he programmed the chip in is stk500 board, not in the servo tester circuit..

will build it tonight, program it and when I confirm it is working, I will post the info..

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: 16578
Joined: Tue Dec 27, 2011 1:24 pm
Country: -
Location: Poole, Dorset, UK

Re: Servo Tester - Read Receiver Pulses with Arduino

Post by MikeB » Sat Mar 02, 2013 8:08 pm

If you have AVRstudio installed, you can run the programming option in disconnected mode, select your AVR device, then use the fuses tab. When you change a checkbox to choose an option, the hex fuse values change at the bottom of the window.

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

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

Re: Servo Tester - Read Receiver Pulses with Arduino

Post by jhsa » Sat Mar 02, 2013 8:18 pm

Thanks Mike..
What is the option we that bricks the chip? the one we should leave alone?
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: 16578
Joined: Tue Dec 27, 2011 1:24 pm
Country: -
Location: Poole, Dorset, UK

Re: Servo Tester - Read Receiver Pulses with Arduino

Post by MikeB » Sat Mar 02, 2013 9:09 pm

Just make sure the oscillator is either the internal RC or an external crystal, NOT an external clock.

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

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

Re: Servo Tester - Read Receiver Pulses with Arduino

Post by jhsa » Sat Mar 02, 2013 9:20 pm

Ahh, that's how we brick them then. will have to do some really good reading..

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
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 » Sat Mar 02, 2013 9:46 pm

And don't disable the reset pin!
-Gohst

Sent from my LG-P999 using Tapatalk 2

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

Re: Servo Tester - Read Receiver Pulses with Arduino

Post by jhsa » Sat Mar 02, 2013 9:56 pm

I will pay also attention to that.. Thanks Ghost.. This forum is a school..

Thank you guys, I've learnt a lot so far..

Joao
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: 18956
Joined: Tue Dec 27, 2011 5:13 pm
Country: Germany

Re: Servo Tester - Read Receiver Pulses with Arduino

Post by jhsa » Sun Mar 03, 2013 4:19 am

Just finished building the servoTester1.. It works..
Part from the email regarding the fuses that I received from Mikael who designed it.
ATTiny2313.

No fuses set at all should work fine.
The most important is the clock selection, where it should be set up
to crystals above 8 MHz, and 14 CK + 65 ms start-up time.
This gives these fuse bytes:
EXT = 0xFF
HIGH = 0xFF
LOW = 0xFF

Remember to program both the flash and the EEPROM.

You can optionally set the EESAVE fuse. Then if you make changes to
the program and want to flash a new version, then you won't have to
program the EEPROM again.
The HIGH fuse byte should then be 0xBF instead.
AVR Studio didn't want to program the HIGH Fuse 0xBF. gave some kind of error and set the fuse to 0xF9 I think.
But it is working. will post some photos and a little video later.. Now it's too late here :)
Bed time is long gone :mrgreen:

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 » Sun Mar 03, 2013 4:54 am

cool. Glad you got it working. I was curious what the eeprom would be used for in this program. looks like he stored text strings in eeprom, if my detective work is right :) Looking forward to some eye candy

Code: Select all

.eseg
MenuOutText:		.db "Out     "
MenuInText:		.db "In      "
MenuInAvgText:		.db "In avg  "
MenuTransText:		.db "Transp. "
MenuSwpMinText:		.db "Swp min "
MenuSwpMaxText:		.db "Swp max "
MenuSwpStepText:	.db "SwpStep "
MenuSwpOnText:		.db "SweepOn "
InitText1a:		.db "ServoTes"
InitText1b:		.db "ter 2.05"
InitText2a:		.db "060823 e"
InitText2b:		.db "jberg.dk"

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

Re: Servo Tester - Read Receiver Pulses with Arduino

Post by jhsa » Sun Mar 03, 2013 11:48 am

Yes, they are.. I was looking for the initText to change it but didn't find it in the code ;) Now I know why he he.
It would be nice if he stored our custom settings in the eeprom.. like the sweep speed and the limits.. that would have been nice because we have to reprogram every time we want to sweep a servo.. the most important being the sweep speed as the limits are quite different on every servo..

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 » Sun Mar 03, 2013 4:10 pm

yes that is what I was expecting in eeprom, custom settings. I'm sure there is a good reason he wrote like this . It's just a lack of understanding on my part. hmm. wonder what he changed on V2 ?

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

Re: Servo Tester - Read Receiver Pulses with Arduino

Post by jhsa » Sun Mar 03, 2013 4:18 pm

If I would find a cheap encoder I would build it.. I have all the rest already..,
Later will post a video and some photos from the version 1..

Ans send it also to Mikael, who was very kind to answer all my mails

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: 18956
Joined: Tue Dec 27, 2011 5:13 pm
Country: Germany

Re: Servo Tester - Read Receiver Pulses with Arduino

Post by jhsa » Sun Mar 03, 2013 4:25 pm

It would be interesting to find out why the chip didn't accept 0xBF as HIGH fuse and changed it to 0xF9.. Or is it the same?

I know something similar was happening to some people with the SMD version of the Atmega 328 on the sound module. That one of the fuses was changing..

Why would that happen?

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 » Sun Mar 03, 2013 5:00 pm

yea that is expensive
http://www.conrad.com/ce/en/product/705 ... IL-Max-5-W


maybe this one costs less. without knob and breakout ? dont know about shipping?
even has led lights:)

in my toolbox
20130303_114802.jpg
$3 encoder https://www.sparkfun.com/products/10596
$1 knob https://www.sparkfun.com/products/10597
$4 breakout https://www.sparkfun.com/products/10954

I havent used it. My only experience with rotary encoder was when the volume knob on my car stereo was acting up. Removed face plate and took it apart. studied how rotary encoders work. I musta spilled some drink in there. took apart encoder and cleaned contacts :) works good now.

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 » Sun Mar 03, 2013 5:31 pm

jhsa wrote:It would be interesting to find out why the chip didn't accept 0xBF as HIGH fuse and changed it to 0xF9.. Or is it the same?
AVR Studio didn't want to program the HIGH Fuse 0xBF. gave some kind of error and set the fuse to 0xF9 I think.
Well I checked out the online fuse calculator as mentioned gohsthb . Gonna have to use that more often. I like it better than the 'avr burn o mat' software. assuming you are using ATtiny2313 MCU

You probably dont want 'BF'. It turns off 'SPIEN Enable Serial programming and Data Downloading' You wouldnt be able to program it any more, if I am reading correctly. For him that worked because he removes his chip from the circuit and probably uses a parallel high voltage programmer. So your software saved itself from being locked out

After poking around I'm guessing when you thought 'F9', it really was '9F'

'9F' is what you want 'Preserve EEPROM memory through the Chip Erase cycle; [EESAVE=0]'
'F9' does not turn on 'Preserve EEPROM memory' . It turns on brown out detection

for me the whole save EEPROM memory in this application doesnt matter much. Unless I overlooked something in the code, which is very possible :), all he is saving in EEPROM are those strings mentioned above. So rewrite them when you upgrade the flash. Not like you are losing some custom configuration setting that you had implemented. But yes, it saves you one step if you are only upgrading the code, and not the text strings. It's also where he stores his custom information regarding revision and ?website?

This is fun. i'm learning about avr and assembly and havent had to buy any parts :)

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

Re: Servo Tester - Read Receiver Pulses with Arduino

Post by ReSt » Sun Mar 03, 2013 5:36 pm

jhsa wrote:
I know something similar was happening to some people with the SMD version of the Atmega 328 on the sound module. That one of the fuses was changing..

Why would that happen?

Thanks,
João
That was because some bits in the fuse byte are not used.
A fuse that is not set, is high, but the 328 reports these bits as low bits
So in the byte that was written, the bits were high (do not activate the fuse) and on read back they were shown as low.

Reinhard

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

Re: Servo Tester - Read Receiver Pulses with Arduino

Post by jhsa » Sun Mar 03, 2013 5:57 pm

rperkins wrote: You probably dont want 'BF'. It turns off 'SPIEN Enable Serial programming and Data Downloading' You wouldnt be able to program it any more, if I am reading correctly. For him that worked because he removes his chip from the circuit and probably uses a parallel high voltage programmer. So your software saved itself from being locked out
So, AVR studio actually prevented the idiot here from destroying the chip .. well done.. :mrgreen:

Is it possible to edit the eeprom? I would like to customize the text strings a bit ;)

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 » Sun Mar 03, 2013 7:05 pm

well did you compile his source code and upload that into your MCU, or did you just upload his provided hex ? I wouldnt know how to begin to compile his source. Seems to me that you could change the strings a little, staying within the boundaries of how they are typed, recompile and upload. I can compile some 'C' with a makefile, but not without. Can compile in arduiono and locate the hex, but never done it from the source code. Hopefully the author will help you. Just remember my help on this is the blind leading the blind :)
What I have learned so far was taken from the 'AVR assembly guide ' which BTW, mentions windows 3.11 :roll:
http://www.atmel.com/Images/doc1022.pdf
4.5.3
DB-Define constant
byte(s) in program
memory or E2PROM
memory

The DB directive reserves memory resources in the program memory or the EEPROM
memory. In order to be able to refer to the reserved locations, the DB directive should be
preceded by a label.
The DB directive takes a list of expressions, and must contain at least one expression.
The DB directive must be placed in a Code Segment or an EEPROM Segment.
The expression list is a sequence of expressions, delimited by commas. Each expres-
sion must evaluate to a number between -128 and 255. If the expression evaluates to a
negative number, the 8 bits two's complement of the number will be placed in the pro-
gram memory or EEPROM memory location.
If the DB directive is used in a Code Segment and the expressionlist contains more than
one expression, the expressions are packed so that two bytes are placed in each pro-
gram memory word. If the expressionlist contains an odd number of expressions, the
last expression will be placed in a program memory word of its own, even if the next line
in the assembly code contains a DB directive.

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

Re: Servo Tester - Read Receiver Pulses with Arduino

Post by jhsa » Sun Mar 03, 2013 7:32 pm

:mrgreen: I just flashed his files obviously :mrgreen:
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”