Recent Posts

Pages: [1] 2 3 ... 10
1
Deutsch / Re: I2C Bus Gleisbildstellwerk...
Last post by MicroBahner - Today at 11:31 am
Mein Tip: beschäftige Dich mit Automaten (state machines)
Das kann ich dir auch nur wärmstens empfehlen.
Das 'Stellwerk' für meinen Modellbahnhof ist auch komplett in dieser Technik erstellt. Da sind etliche Automaten drin: für jede Fahrstraße, für den Zustand jedes Gleisabschnitts ... Zur Eingabe über 60 Schalter ( per I2C abgefragt). Und alles auf einem Master-Prozessor, der nur die Stellbefehle für Weichen und Signale dann per I2C an die Slaves sendet.
Ist eine sehr übersichliche (wenn man's einmal kapiert hat ;) ) und leistungsfähige Programmiertechnik.
2
Deutsch / Re: NRF24L01+ probleme
Last post by Whandall - Today at 11:30 am
Beide gleich zu verdrahten hätten den Vorteil, dass du nur einen Sketch hast,
keine Chance einen falschen zu brennen.

Beide Knoten (anfangs sind es beide Receiver) zeigen unterschiedliches Verhalten.

Der Transmitter scheint sich wegzuhängen (keine Ausgabe bei 'T'),
der Receiver liest anscheinend Schrott.

Was macht der Receiver wenn du ein 'T' eingibst?
3
Français / Re: Fonction ITOA en STRING ?
Last post by Ghostly - Today at 11:30 am
parce que je veux l'afficher sur mon écran lcd nokia mais la fonction ne m'affiche rien sur l'écran
Code: [Select]
LcdString(itoa(chaine,"%d",cpt));
je n'est pas d'erreur mais il ne me transmet rien
4
Français / Shield Model 4 relais R3 ou ca...
Last post by Marliru - Today at 11:29 am
J'ai en m'a possession un shield relais mais il me parrait peu costaud je me demande si il ne faudrait pas mieux que j'achete une carte avec relais? J'ai en ma possession une carte Leonardo Ethernet.
5
Because you havent declared voltage in loop

Code: [Select]
void loop() {
  // Put your main code here, to run repeatedly:
  // read the input on analog pin 0
  int analogInpin = analogRead (A0); { // The Sensor, which is OPB705
  // Convert the analog reading (which goes from 0 - 1023) to a voltage (0 - 5V):
  float voltage = analogInpin * (5.0 / 1023.0);
  // print out the value you read:
  Serial.println (voltage);
 [color=red] }[/color] //THIS BRACKET HERE CLOSES LOOP
  // Part 1 Read the sensor state
if ( 'voltage' > 1.5 ); // If OPB705 register HIGH volt frequency

  goto void loop; // Return to start

  } else {  // If OPB705 register LOW volt frequency

  continue; // Go to the next bracket
}
///Part 2-7 counter harddone
  // Activate the sequence and then go back every 4 counts
  if (sensorCounter % 4 == 0) {
// Part 4
  digitalWrite(pin1, LOW); // Digital pin 8 is getting low frequency so pneumatic piston pulls back
  digitalWrite(pin2, HIGH); // Digital pin 9 is getting low frequency so pneumatic piston pulls forth
// Part 5
  delay(3000); // Wait 3 seconds
// Part 6
  digitalWrite(pin1, HIGH); // Digital pin 8 is getting low frequency so pneumatic piston pulls forth
  digitalWrite(pin2, LOW); // Digital pin 9 is getting low frequency so pneumatic piston pulls back
// Part 7
  goto void loop; // Go to start again
  } else {
   return;
}
}

What would you suggest to use instead of continue; to go to the next process of my coding?
6
If you want easy, grab a USB phone charger :) But that will only give you power for the Arduino, leds and switches.

The relays are a different story. First, you link the 24V version :p And second, regulating to a voltage which is might matched at the input (so regulate to 12V while 12V at the input) is hard. Most regulators go out of regulation and just give you a slightly lower voltage on the output. Luckily, relays are not that critical. So you could just use a buck converter for them. An you are probably lucky, you talk about 12V to 24V so I assume a car? If a car battery is at 12V it's very low :p And while running the voltage is closer to 14V (or 28V for the "24V" situation in trucks). So pick a converter which can handle that. But because of this, if you set the output to 12V an you input 14V they will regulate.

Other option would be to use zeners and burn a piece of the power to the 12V relays when connected to 24V. But you would have to check if you can get away with heat production etc.

Ow, and yes you can make a buck converter from scratch (with an IC) but PCB layout then is very important (and kind of a black art). So grabbing a off the shelf is easier. And if you grab a small of the shelf you can just solder it to your PCB directly. I just treat those small converters as a single IC like a 7805 replacement.
I am fully aware of what you're saying, but I want to keep parts to a minimum and have it all work in as small a space as possible. So, two power supplies (24 to 12V + 12V to 5V) is too much. For that reason I'm thinking of using 5V relays so everything runs at 5V. I'm not using a car battery, but rather mount it in a car's electronics so I need to compensate for the alternator, which runs at 14.x Volts, or 28.xV (on a 24V truck).

7
Hello Brianeo,

Are you an educator, a school teacher or are you looking for a self-taught kind of curriculum? Maybe I can point you out towards the kind of resources you are looking for ;-)
8
Code: [Select]
            //This WORKS! The result is the same as shown in the TinyGPSPlus sample code!
            //distanceKm = ((unsigned long)TinyGPSPlus::distanceBetween(gps.location.lat(),gps.location.lng(),LONDON_LAT,LONDON_LON)/1000);

That comment is true ONLY if you are in EXACTLY the same place as the author of the TinyGPSPlus example.

Code: [Select]
            //***** THIS FAILS! ******
            //Compute distance between Points A and B and capture distance incrementally in global variable
            distanceKm = distanceKm + ((unsigned long)TinyGPSPlus::distanceBetween(flat,flon,flat_ref,flon_ref)/1000);

Print out flat, flon, flat_ref, and flat_lon before hand. Just what does adding 0.5 to flat and flon mean? Print out the actual value returned, not just the modified distanceLm value.
9
This achieves what I wanted to do so thank you for all your help.  I can post a video of it all in action if anyone is interested.

Code: [Select]

// Libraries
#include <VarSpeedServo.h>

// Variables
VarSpeedServo SignalServo;
VarSpeedServo TurnoutServo;
VarSpeedServo UncouplerServo;

// Receiver channels
const byte SignalsInputPin = 22;
const byte TurnoutsInputPin = 24;
const byte UncouplerInputPin = 26;
const byte CHANNELS = 3;  // Number of channels
const byte ChannelPins[CHANNELS] = {TurnoutsInputPin, SignalsInputPin, UncouplerInputPin};
const byte SignalsServoPin = 52;
const byte TurnoutsServoPin = 50;
const byte UncouplerServoPin = 48;
boolean ChannelStatePrevious[CHANNELS];
unsigned long ChannelChangeTime[CHANNELS];
const int CHANNEL_MAX = 1600;  //control knob value max (microseconds)
const int CHANNEL_MIN = 1100;  //control knob value min (microseconds)
const int CHANNEL_THRESHOLD = ((CHANNEL_MIN + CHANNEL_MAX) / 2); // Center point
const unsigned long CHANNEL_DEBOUNCE = 5;

void setup() {
  for (int i = 0; i < CHANNELS; i++) {
    pinMode (ChannelPins[i], INPUT);            //set up input pins

    SignalServo.attach(SignalsServoPin);        //attach signal servo  
    TurnoutServo.attach(TurnoutsServoPin);      //attach turnout servo
    UncouplerServo.attach(UncouplerServoPin);   //attach uncoupler servo
    
  }
}

void loop () {
  // Convert the channel inputs to switch state changes
  for (int i = 0; i < CHANNELS; i++)  {
    boolean channelState = pulseIn(ChannelPins[i], HIGH) > CHANNEL_THRESHOLD;
    if (channelState != ChannelStatePrevious[i] && millis() - ChannelChangeTime[i] >= CHANNEL_DEBOUNCE) {
      ChannelStatePrevious[i] = channelState;
      ChannelChangeTime[i] = millis();
      // The channel has changed state.  Do something!
      switch (i) {
        case 0:
          SignalsChange(channelState);
          break;
        case 1:
          UncouplerChange(channelState);
          break;
        case 2:
          TurnoutsChange(channelState);
          break;
      }
    }
  }

  //Servo animations
}

  void SignalsChange(boolean newState) {
    // Move the signal servo to the new position
    SignalServo.write((newState ? 66 : 86), 30, true);        //first value signal halt movement, second value clear movement
    SignalServo.write((newState ? 76 : 70), 10, true);
    SignalServo.write((newState ? 86 : 83), 10, true);
    SignalServo.write((newState ? 66 : 86), 30, true);
  }

  void UncouplerChange(boolean newState) {
    // Move the signal servo to the new position
    UncouplerServo.write((newState ? 110 : 40), 10, true);
  }

  void TurnoutsChange(boolean newState) {
    // Move the turnout servo to the new position
    TurnoutServo.write((newState ? 110 : 62), 6, true);
  }
10
This is re-written for you
Code: [Select]
int analogInpin = A0; // The reader
int pin1 = 8; // Pneumatic piston 1
int pin2 = 9; // Pneumatic piston 2

void setup() {
  // Put your setup code here, to run once:
  pinMode (analogInpin , INPUT); // Sets the analog pin A0 as input
  pinMode (pin1 , OUTPUT); // Sets the digital pin 8 as output
  pinMode (pin2 , OUTPUT); // Sets the digital pin 9 as output
  Serial.begin(9600);
}

void loop() {
  // Put your main code here, to run repeatedly:
  // read the input on analog pin 0
  int reading = analogRead (A0); { // The Sensor, which is OPB705
  // Convert the analog reading (which goes from 0 - 1023) to a voltage (0 - 5V):
  float voltage = reading * (5.0 / 1023.0);
  // print out the value you read:
  Serial.println (voltage);
  // Part 1 Read the sensor state
if ( voltage < 1.6 )
{
///Part 2-7 counter harddone
  // Activate the sequence and then go back every 4 counts
  if (sensorCounter % 4 == 0) {
// Part 4
  digitalWrite(pin1, LOW); // Digital pin 8 is getting low frequency so pneumatic piston pulls back
  digitalWrite(pin2, HIGH); // Digital pin 9 is getting low frequency so pneumatic piston pulls forth
// Part 5
  delay(3000); // Wait 3 seconds
// Part 6
  digitalWrite(pin1, HIGH); // Digital pin 8 is getting low frequency so pneumatic piston pulls forth
  digitalWrite(pin2, LOW); // Digital pin 9 is getting low frequency so pneumatic piston pulls back
// Part 7
  }
  
}


However you need to declare sensorCounter as you have no mention of this
Pages: [1] 2 3 ... 10

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy