Pages: [1] 2   Go Down
Author Topic: 2 tests and 2 failures - what am I doing wrong?  (Read 1815 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 1
Posts: 23
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi All,

Firstly - I am fairly new to the Arduino but have experience in C.

I have successfully combined the Arduino Mega with LED's, Thermistors, LDR's ECT and started to look at some bigger things. I first looked at working with servo's, I used a cheap servo that I had lying around that originally came out of a RC toy car (HPI Minizilla).  I wired everything up and used the 'sweep' example from the Arduino website to try it out but it wouldn't work - the servo did power up but didn't move.  I attached an LED to pin 13 and programmed a 'blink' at the end of every loop to check it was cycling and it was, but I found no reason as to why the servo didn't move.

My second task was to use a Sparkfun LIS3LV02DQ Triple Axis Accelerometer with my Mega so I used the suggested method found on the cool components website

I soldered and wired up everything perfectly but again - nothing. So this time I used the Serial.println at various stages in the code to detect what was happening.  I found that everything works until the Arduino starts to talk to the sensor - at this point the code stops running altogether???

My question is this - have I done something wrong as the examples are written for Duemilanove and not the Mega?  If so - what do I need to change?

Or - Am I doing something completley wrong?

Please put me out my misery!

Thanks in advance,

James
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 301
Posts: 26247
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
a cheap servo ... that...came out of a RC toy car (HPI Minizilla

Depending on how much the toy originally cost, I wouldn't necessarily expect it to work like a hobbyist servo. Depending on production volumes, it could have a completely proprietary control protocol.
I'd try to examine the toy using an oscilloscope to see what controls it expected.

Try finding an R/C model shop, and buy a cheap Futaba 3003.
Make sure you read the servo library documentation carefully.

Make sure you join the grounds between your separate power supplies.

Quote
I soldered and wired up everything perfectly
How do you know this?
Again, an oscilloscope is great help.
Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

0
Offline Offline
Newbie
*
Karma: 1
Posts: 23
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks for your quick reply!

With regards to the servo - I used to work for the UK Futaba distribution company so I will get one through them and try that out first.  I dont have an oscilloscope so I can't check it that way.

 
Quote
Make sure you join the grounds between your separate power supplies.

What do you mean by seperate power supplys?  I was using the 5v and ground from the Mega - is that not right - Do I need to power the servo separatley?

Quote
How do you know this?

I used my multimeter to check the connections from one side (header pins) to the other side (solder) - I felt that was a quick and easy test?  Is it not?
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 619
Posts: 33989
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
at this point the code stops running altogether???

No code never stops running, it might be running out of control or sulking in a tight loop but it never stops. Remember that and hunt down where it is going to.
Logged

0
Offline Offline
Faraday Member
**
Karma: 16
Posts: 2857
ruggedcircuits.com
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Also seeing the actual code would be helpful.
Logged

0
Offline Offline
Newbie
*
Karma: 1
Posts: 23
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Sorry - my first post on this thread was actually my first post on this site so couldn't post links but can now so here they are:

Servo : http://arduino.cc/en/Tutorial/Sweep

3 Axis sensor : http://www.nearfuturelaboratory.com/2006/09/22/arduino-and-the-lis3lv02dq-triple-axis-accelerometer/

The code was unaltered except for my 'blink' or 'Serial.println' debug lines, which worked but I havent kept the code  :-[
Logged

0
Offline Offline
Faraday Member
**
Karma: 16
Posts: 2857
ruggedcircuits.com
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Well, I don't have an Arduino Mega but sleuthing through the code reveals a potential problem (maybe somebody can correct me if necessary).

Pin 9 on the Mega is Port H pin 6, which is the OC2B output compare pin for Timer 2, but the Servo library uses Timer 1.

I think you have a similar problem with the accelerometer code. It is currently set to use pin 11 for MOSI, 12 for MISO, etc. etc. but pin 11 on the Mega is PB5 which is not MOSI, pin 12 on the Mega is PB6 which is not MISO, and so on.
Logged

London
Offline Offline
Tesla Member
***
Karma: 10
Posts: 6255
Have fun!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

If you use the standard Arduino servo library on the mega you need to use pins 11 and 12
Logged

0
Offline Offline
Newbie
*
Karma: 1
Posts: 23
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

That sounds about right!  I was thinking it was going to be something like that!

Thanks to Rugged Circuits and mem for pointing those out!

Where do I get that information regarding the types of pins so I can solve myself in future?

I will try the servo pin variation and let you know!
Logged

London
Offline Offline
Tesla Member
***
Karma: 10
Posts: 6255
Have fun!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

It should be mentioned in the servo reference but it is not.
http://www.arduino.cc/en/Reference/Servo

I have posted a note asking for this to be updated.
Logged

0
Offline Offline
Newbie
*
Karma: 1
Posts: 23
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Good idea - thanks mem! smiley-wink
Logged

0
Offline Offline
Newbie
*
Karma: 1
Posts: 23
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
If you use the standard Arduino servo library on the mega you need to use pins 11 and 12

If I just change the pin in the example from 9 to 11 - should that work or do I need to change something else?  If so - What?
Logged

0
Offline Offline
Newbie
*
Karma: 1
Posts: 23
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Just tried changing the pin number in the code but still no joy  :-[

I tried to use 11 and 12

Am I forgetting something?
Logged

London
Offline Offline
Tesla Member
***
Karma: 10
Posts: 6255
Have fun!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

If you have not already tried it,  run the example Servo code (after changing the pin numbes)
Logged

0
Offline Offline
Newbie
*
Karma: 1
Posts: 23
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Sorry - maybe I should have explained better.  I am still trying the example 'sweep' servo code using the suggested pin 9, and your sugegsted pins 11 and 12.  All variations fail!
Logged

Pages: [1] 2   Go Up
Jump to: