Show Posts
Pages: [1] 2 3 4
1  Using Arduino / Sensors / Re: Reading from an RC remote stick's potentiometer on: September 07, 2014, 01:23:48 pm
The yellow one is also connected to ground via a 10k Ohm resistor.

Here is your issue: you are altering the voltage bridge effect of the potentiometer. 

I would recommending comparing your circuit to the following example:  It covers the correct way to connect a potentiometer circuit and show how to read it.
2  Using Arduino / Project Guidance / Re: muti door locks on: September 03, 2014, 05:06:47 pm
Depending your your RFID reader, one Arduino should have sufficient I/O capacity to control 4 locks and connect to 4 readers.

For example, this reader provides a serial output and would only need 1 input pin on the Arduino to read it.  Controlling a door lock should only take 1 digital output pin.  This would total 8 pins on your Arduino (less then available), but would require software serial for the Arduino UNO.  The performance capabilities should be fine for the Arduino for this purpose, the biggest issue would be the additional hardware you would need to extend your signals from your Arduino to the RFID pads and to the locks.
3  Topics / Robotics / Re: Changing PWM value in function of an other pin value on: September 03, 2014, 03:47:40 pm
It looks like there is a PID library here:

As my experience with PID is limited at this point, it would reference you to that documentation.
4  Topics / Robotics / Re: Changing PWM value in function of an other pin value on: September 03, 2014, 02:32:09 pm
This is putting your code segments together to fit with my sudo code.  It compiles, but I don't have your hardware setup to test its functionality.  As written it will only update the Throttle at less then 1 time a second because your code to gather the power average takes 1 second in delay time alone.  If you don't need a 1 second average or can use a rolling average (all depends on your application), you could get a more frequently update cycle.

With the current update cycle it will take more then 4.25 minutes to go from no power to full power or full power to no power. 

int ESCpin = 11;        // ESC signal wire connected to pin 11 on arduino
int Throttle = 0;       // variable to store PWM value
float GoalWatt = 10.0;   // Set point for Goal wattage
void setup() {
void loop() {
  float average = 0;
  for(int i = 0; i < 1000; i++) {
    average = average + (0.0049 * analogRead(A4)/0.185 -13.5447) / 1000;
  if(average > GoalWatt) {          // Higher then goal
    if(Throttle > 0) Throttle--;    // decrease Throttle if greater then min 
  } else if (average < GoalWatt) {  // Lower then goal
    if(Throttle < 255) Throttle++;  // increase Throttle if less then max 
  analogWrite(ESCpin, Throttle);    // Update PIN output
5  Topics / Robotics / Re: Changing PWM value in function of an other pin value on: September 03, 2014, 02:09:11 pm
Yes it is exactly what i need!!! smiley smiley smiley

how can i put this code on my sketch?

for sure i would like to make this change as fast as it possible, how fast can it be?

To answer how fast it can be, I need to know why your example was averaging 1000 (slightly over one second of time) samples for the power measurement.
6  Topics / Robotics / Re: 360 degree rotating dome with limit switches on: September 03, 2014, 12:14:44 pm
You don't need a PID controller to center a rotating object via limit switches and a stepper motor.

If you are using a stepper motor and 2 limit switches and want to move to the middle of the two switches you could use the following sudo code:
steps = 0
while (switch one not pressed) {
   Step right
while(switch two not pressed) {
  Step left
  steps += 1

steps = steps / 2
for (i = 0; i < steps; i++){
 step right

that will have you within 1/2 a step of centered - to the accuracy of your stepper motor.  You will need to address in your code the max speed that your stepper motor can turn, etc.
7  Topics / Robotics / Re: Changing PWM value in function of an other pin value on: September 03, 2014, 12:08:02 pm

From what you are describing, it sounds like you are looking to make a PID controller.

Sudo code that could get you a first pass on what you are wanting:
Throttle = start point
loop start
   Check Current Power
   if Current Power < Target Power: increase Throttle
   if Current power > Target Power: decrease Throttle
loop end

Your power sample code snippet is taking an average over a full second, is that needed for your application?
If so, how rapidly do you need your Throttle to adjust to variations in power usage?
8  Topics / Robotics / Re: Xbee communication. on: September 02, 2014, 05:40:28 pm
Lets start with some questions:

How are you connecting the Xbee's to your Arduinos?

Have you looked at the reference information for your connection method (IE the official shield: has information that could explain your issues)

Have you tried your receiver code via just the USB (no shield) to see if it works?
Have you tried your sender code via just the USB (no shield) to see if it works?

Looking at your code, your receiver code doesn't need the delay, I don't think that is your issue, but it could cause some odd or unexpected behavior.
9  Topics / Robotics / Re: 2WD Platform with compass on: January 21, 2013, 06:00:30 pm
That sounds great.  Glad you learned something.  Looking forward to seeing your code.

I believe a gyroscope can be used for dead reaconing and would be less influenced by the magnetic field.
10  Topics / Robotics / Re: 2WD Platform with compass on: January 21, 2013, 09:06:53 am
If you are averaging the last 50, you are lagging your adjustments to much.

From the description on how you are adjusting your speeds, it sounds like you are only using the I part of a PID circuit, if you wanted to go "round one" simplification of PID configuration I would do the following:

Run a 3 sample rolling average for your sample set.
Instead of having your loop change speeds by 1 increment, each cycle you are off direction, change your speed based on the difference between expected direction and actual direction: IE:

If your expected heading is 180 degrees, but you are going 160 degrees, drop the speed for the side needed proportional the error amount.  For example, drop the speed by 20 creating speeds of 255, 235.  You will probably need to work with your multiple to find a smooth offset amount - IE you may want 255, 245 (1 per 2 deg) or 255, 205 (2 per 1 deg) or some formula.  This would be the P part of a PID logic.
11  Topics / Robotics / Re: 2WD Platform with compass on: January 20, 2013, 08:16:23 pm
A few suggestions that might help:

look into PID logic for your speed adjustment calculations
You might want to use a running average of the last 3-5 compass outputs to smooth any jitter in its output

Does your robot always pull left or right?
If so you might want to look at trying different ratios of speeds - IE 253 and 255 at max speed

12  Using Arduino / Networking, Protocols, and Devices / Re: Serial communication distance. on: January 01, 2013, 09:46:04 pm
What data rate do you need?
Are you going to try to level the signals at TTL levels or use a converter chip for RS422, RS232, etc?

Data rates of up to 100K bits / second and distances up to 4000 Ft. can be accommodated with RS422. (
13  Using Arduino / Motors, Mechanics, and Power / Re: I had a problem on L293D on: February 14, 2012, 07:06:30 am
I don't see anything wrong with the code that isn't turning the motor on and off, at least nothing that is different between it and the other code that would cause it to "hang." Have you tried putting in a few debugging statements in your code? (IE flash the LED or send data to the serial interface).

You might want to check  your hardware, you may be getting interference between your motors and your IR receiver.  You seem to be able to receive IR signals when the motors are off,  but not when on.
14  Using Arduino / Motors, Mechanics, and Power / Re: I had a problem on L293D on: February 13, 2012, 04:00:54 pm
Please post you whole code, both the "working" and "not working" versions, otherwise we are left to guessing and divination.

Normally you want to avoid "delay" in code were you are doing multiple things and this may be your problem (see blink with out delay example code).
15  Using Arduino / Programming Questions / Re: Help needed with controlling a robot using obstacle avoiding sensors. on: February 03, 2012, 07:47:42 am
This isn't going to work either because you are doing a logical compare and sending it as the variable to digitalRead

boolean see_NOleft() {
    return digitalRead(sensorPinLO == LOW); // no obstacle on the left side

boolean see_NOright() {
    return digitalRead(sensorPinRO == LOW); // no obstacle on the right side

This is the format you are looking for however you may need to swap the true and false depending on your sensor output.

This function tests the left sensor PIN and returns TRUE if the sensor PIN is LOW and FALSE if the sensor PIN is HIGH
This function is expecting a sensor that give a high value when it detects something in range and a low value when it does not detect something in range

boolean see_NOleft(){
   boolean clear;
      if(digitalRead(sensorPinLO)  == LOW) {
         clear = TRUE;
      } else {
         clear = FALSE;
   return clear;
Pages: [1] 2 3 4