Show Posts
Pages: [1] 2 3 ... 6
1  Forum 2005-2010 (read only) / Syntax & Programs / Re: Robotic Lawnmower - its happening not just a dream on: December 09, 2010, 03:33:22 am
MAKE magazine featured a remote controlled lawn mower in issue 22. (if you have haven't heard of it, its quarterly and issue 24 just recently came out.) The guy was planning on adding a gpsduino, mowing his yard and recording the path, and then using the gps plot to control it. His site is www.rediculouslygoodlooking.com (spelling error intentional) and its what got me interested in arduino.

His full schematic and code is posted here.
http://makezine.com/22/rclawnmower/


Its similar to what I am now working on, but my goals are set much lower for now. I was also liking the wire buried under the yard and having it drive basically like a roomba. I was thinking you could use an electric fence and a dog collar, but i need way more knowledge on interfacing the hardware before i could do something like that.

subscribe to the magazine, itll be the best 30-35 you ever spent.
2  Forum 2005-2010 (read only) / Syntax & Programs / Re: Any Glaring errors in this code? Will it work? on: December 04, 2010, 08:00:44 pm
Thanks for constructive comments, Ill rewrite and change variable names and comment. The reason i used explicit pin numbers instead of variables is because that was how it was done in the various tutorial examples.

As for speed vs direction, I am using 2 motors, one on either side, so to turn left, left side motor goes in reverse, differential/tank drive, so dont they have to be set at the same time?

are you saying I should maybe rewrite using digital input pins and not worry about analog pins until I have directions correct from full high/low?
3  Forum 2005-2010 (read only) / Syntax & Programs / Re: Any Glaring errors in this code? Will it work? on: December 03, 2010, 11:06:17 pm
Quote
Why divide by 8? OK, looking ahead, I see that the idea is to get a value in the range 0 to 127. But, it may be necessary to adjust this based on the actual (range of) value(s) read from the switches. So, the previous question really needs to be answered/ assumption validated before the rest of the code can be effectively analyzed.

Well, I didn't post it here, tho i did post it in the hardware thread, but I shortened it down to two buttons to just try to troubleshoot. I changed the High side button (was 127 + analogreadval/8) to just strictly analogwrite( 9/leftmotorsig, 255) to make sure I wasnt going over 255 to 256 and looping back to zero.
Also, thats why I have serial.begin there, I may have deleted it from the code but I was watching the buttons go from 0-128 (not instantly but with button pressure, IE half pressure would give 64) and it was working.

So I think I've either got a hardware problem or I need to enable the pulldowns on the analog pins. I just picked up a pair of matching pots and Im going to try and rewrite the code using them to see if I can get a better understanding of what's going on.

If there are other things I need to look into before I can declare it a hardware/wiring problem, please inform what else I need to look into. As always, thanks very much!
4  Forum 2005-2010 (read only) / Syntax & Programs / Re: Any Glaring errors in this code? Will it work? on: December 03, 2010, 09:18:27 pm
Quote
Buttons? As in on/off switches? Connected to analog pins? I'm confused. Or, you are. Or we both are.

Well, I am currently Always confused, so at least that part is true. I know I've got a similar thread going in the hardware section but i made it after this one, because all signs point to hardware problems. Anyway, they are variable resistance switches from a console controller, cut from the main board at the ribbon cable and wires soldered to the ribbon.
5  Forum 2005-2010 (read only) / Syntax & Programs / Re: Any Glaring errors in this code? Will it work? on: December 03, 2010, 05:04:07 pm
Im no stranger to failing, thats for sure! I got this breadboarded out, and it was not working as intended. I was getting 2.5v at the pwm pins with nothing pressed, but with buttons pressed It would always go LOW on PWM when one button should have made it go HIGH. I had a pull down resistor on the LOW button, do I need a pull up resistor on the buttons that are supposed to increase the signal? (I may have used pull down/pull up backwards there)
6  Forum 2005-2010 (read only) / Syntax & Programs / Re: Any Glaring errors in this code? Will it work? on: December 03, 2010, 04:58:44 am
I see what you mean, thank you for explaining it to me. Coding is very frustrating for me because I am mechanical/hands on by trade. I figure I'll just keep writing sketches and asking questions and I'll pick it up step by step. I spent a couple weeks with a code book and I probably learned more in a day by just trying to write some code and asking questions (so long as you guys will continue to take pity on me and explain, like you did above smiley-wink )

Thanks again.
7  Forum 2005-2010 (read only) / Syntax & Programs / Re: Any Glaring errors in this code? Will it work? on: December 03, 2010, 04:05:15 am
Quote
No glaring errors, but you've declared names for the PWM pins, so why not use them?

Also LRVal etc have global scope, but you've given local scope to LRVal2 and the other variables.
Is there a reason for this?

Im super new to this (approx 3 weeks), and I just started writing and modifying as I figured it out. Also, some of the global scope stuff is very confusing to me because a lot of the literature out there is for older arduino software, so I see variables defined as const int and #define and it gets me very confused, Basically I cobbled together a bunch of the example and tutorial code, so things like that are my shortcomings as a coder, not an intentional thing.

TBH - I dont really understand what you mean by I've declared names for the PWM pins, so why not use them. Do you mean use the names I declared? If so, thats another "me learning as I go thing" If you mean something else, can you please explain?
8  Forum 2005-2010 (read only) / Syntax & Programs / Any Glaring errors in this code? Will it work? on: December 03, 2010, 02:45:29 am
Yes, It compiles. I am working on a bot that will be controlled by jeenodes, but first I am trying to get it working non remote. The idea is to grab some variable pressure buttons from a couple of old game controllers, and I am hoping this code will work as I intend it to, but I do not have all the hardware present to fully test. The code is intended to control an H Bridge, description of which is in the top comments in code. Also, this code is written in a much longer way that is probably necessary, but it's easy for me to read, and since I find coding to be the most challenging aspect, I don't mind writing it in a longer way if its easier for me to understand.

Anyway, Im hoping that if there are any glaring errors that are going to pop up, someone will notice them now and tell me what areas (perhaps debouncing?) I need to study to make this work 100% as intended.

Code:
//2 signal Wire controlled H-Bridge. Analog-Linear setup
// 0v = full reverse, 2.5v = stop 5v = full forward

#define LeftMotorSig 9  //pwm outputs
#define RightMotorSig 10 //pwm outputs

#define LeftNeutral 8 // neutral indicator left
#define RightNeutral 7 // neutral indicator right

#define LeftReverse 0  // button in
#define LeftForward 1 // button in
#define RightReverse 2 // button in
#define RightForward 3 // button in

int LRVal = 0;
int LFVal = 0;
int RRVal = 0;
int RFVal = 0;

void setup ()
{
  pinMode(LeftMotorSig, OUTPUT);
  pinMode(RightMotorSig, OUTPUT);
  pinMode(LeftNeutral, OUTPUT);
  pinMode(RightNeutral, OUTPUT);
  Serial.begin(9600);
}
void loop ()
{
  LRVal = analogRead(LeftReverse);
  LFVal = analogRead(LeftForward);
  RRVal = analogRead(RightReverse);
  RFVal = analogRead(RightForward);
  
int LRVal2 = LRVal/8;
int LFVal2 = LFVal/8;
int RRVal2 = RRVal/8;
int RFVal2 = RFVal/8;

if ((LRVal2 == 0) && (LFVal2 == 0)) {
  analogWrite(9, 127);
  digitalWrite(LeftNeutral, HIGH);
} else {
  digitalWrite(LeftNeutral, LOW);
}
if ((RRVal2 == 0) && (RFVal2 == 0)) {
  analogWrite(10, 127);
  digitalWrite(RightNeutral, HIGH);
} else {
  digitalWrite(RightNeutral, LOW);
}
if (LFVal2 > 0)
analogWrite(9, LFVal2 + 127);

if (LRVal2 > 0)
analogWrite(9, 127 - LRVal2);

if (RFVal2 > 0)
analogWrite(10, RFVal2 + 127);

if (RRVal2 > 0)
analogWrite(10, 127 - RRVal2);
}
9  Forum 2005-2010 (read only) / Syntax & Programs / Re: How to Serial Analog Input as % of 5v? on: December 02, 2010, 01:14:02 am
Thank you. I had tried "almost" that and I was not understanding the error messages it was returning.

Is Int OK for this? I was reading the example/tutorial pages while waiting for a reply, and I may have learned just enough to be dangerous to myself. smiley-razz

While I understand why we use 1023, would it be better to use 1000, even though it loses a tiny fraction of accuracy? The reason I ask is because with division by 3 there is a chance of running into a repeating number. Or is that taken care of by the .0 you attached to the end of the 1023? Using this code I got an error one time that made everything return 0% until I reset the board, but I could have bumped something.
10  Forum 2005-2010 (read only) / Syntax & Programs / How to Serial Analog Input as % of 5v? on: December 01, 2010, 11:55:03 pm
I'm real new to the world of C based programming, so please, bear with me. I am trying to express TPS position on my car as a percentage. Scale is 0-5v, but really its closer to 0.4v-4.6v. I have tried everything I can think of but either my syntax is wrong or there is some lesson in variables I need to go over.  Here is my code

Code:
#define TpsInput 1
int TpsVal;
void setup()
{
  Serial.begin(9600);
}
  
  void loop()
{
  TpsVal = analogRead(TpsInput);
  Serial.println("TPS SIGNAL" );
  Serial.print(TpsVal);
  delay(1500);
}


I thought division by 1023 would get me the % I want, since using INT, but instead it turns up a weird value. I'm watching the 0-1023 on serial, so I know this much of the code is working. Can anyone help me out with what I am missing or suggest a tutorial I should go over? It seems like most things I find are using C? or Processing? besides the Arduino code, and since I know nothing about either of those, I am having a hard time learning through study of them. Thanks.
11  Forum 2005-2010 (read only) / Development / Re: Solar panels on: November 24, 2010, 05:21:49 am
Quote
Another thing to do (as you mentioned) is use the "deep earth" temp that never really varies and rig up a heat exchanger. Just bury X metres of pipe in the ground and circulate between that and a "radiator" in the house. Because it's a closed system there's very little energy used to move the water and you don't have the legionnaires problem.

forgive me for being uninformed, but what is the legionnaires problem?
12  Forum 2005-2010 (read only) / Interfacing / Re: Presence detection on: January 11, 2011, 12:24:56 pm
I would probably use reed sensors at the doors to each room, because that would be the easiest way for me to implement it.

Depending on where the arduino is located versus the sensors, you could just code it so that using a PIR would trigger whatever ON but would never shut it off until you hit the reset button the arduino. Basically it would only have 2 states, OFF and ON, and OFF would be its default on start up.

13  Forum 2005-2010 (read only) / Interfacing / Re: Calculating Pulse from encoder to Ard. Duemilanove on: January 14, 2011, 03:20:53 pm
Can he not just use PulseIn()? Seriously don't know, just trying to be helpful.
14  Forum 2005-2010 (read only) / Interfacing / Re: Smashed up Bot leads to some hardware questions ;) on: January 14, 2011, 03:23:57 pm
Thank you for the explanations.
15  Forum 2005-2010 (read only) / Interfacing / Re: Smashed up Bot leads to some hardware questions ;) on: January 13, 2011, 08:04:53 pm
Quote
I give you full credit for "hole in wall", well done !
Thanks! ;D
I realize it's one of those things some people might not be able to laugh at, but I found it hysterical. I'll take a great story for half an hours fix and $5 in spackle any day smiley-wink

Now that I've got everything separately switched and it's very controllable with a 12v source, I am putting the parallax idea on hold.

What I would really like to play with next is some sort of stepper motor to control a rotating body after welding a couple of supports across the midsection. After looking at steppers I had a question.

Is there a preferred number of wires? I see some have 4 and some have 6 or more, which would take a lot of I/O pins.
Pages: [1] 2 3 ... 6