1291
Vos projets / Re : Commande d'itinéraires par arduino
« le: mars 14, 2015, 02:40:29 pm »
Merci Pierre,
Ça correspond à la définition que j'ai prise pour mon réseau
Ça correspond à la définition que j'ai prise pour mon réseau
Le forum LOCODUINO est consacré aux discussions ayant trait à l'utilisation de l'Arduino dans les automatismes et les animations pour le train miniature. Nous avons eu récemment quelques inscriptions de personnes ayant des projets plus généraux mais surtout inapplicables au train miniature. Si votre projet ou vos questions ne concernent pas le modélisme ferroviaire, ne vous inscrivez pas, vous perdriez votre temps et nous aussi.
Cette section vous permet de consulter les contributions (messages, sujets et fichiers joints) d'un utilisateur. Vous ne pourrez voir que les contributions des zones auxquelles vous avez accès.
Par contre, on ne choisit pas le plus court. C'est souvent celui qui génère le plus d'incompatibilités avec les autres.
On décide de prendre celui qui va le plus à gauche.
Une fois qu'un itinéraire est construit, on ne peut plus utiliser ses aiguilles tant que le train ne les a pas "effacées" en roulant dessus.
Quand le train parcoure l'itinéraire, il en efface les aiguilles une à une.
C'est cette notion qu'on appelle "souplesse".
Une fois une aiguille effacée, elle devient immédiatement disponible pour un autre itinéraire.
Si on va jusqu'au bout du raisonnement, l'itinéraire est accroché non pas à sa voie d'origine, mais à sa voie d'extrémité.
PS : j'ai essayé de mettre une image, mais je n'ai pas compris comment faire.
Je continue d'avancer pas grand chose est montrable pour le moment.
Je me posais donc la question de la distance entre un arduino et on va dire son composant commandé par exemple une DEL.
Quelle est la distance maximale entre les deux ?
Je trouve le principe très bien pensé. Félicitations!!!
Petites questions :
1) Comment se fait la détection? Uniquement via la mesure de la FCEM ou y a t-il autre chose qui permet de détecter la machine?
2) Si je comprends bien, tu mesures la FCEM pour en déduire la vitesse de la locomotive. Cela marche ben avec des locomotives analogiques, mais cela marche t-il aussi avec des locomotives équipées de décodeurs?
3) Quel logiciel utilises tu pour faire tes typons?
4) qu'appelles tu une alimentation "one step beyond"? Je ne trouve pas d'article sur le net expliquant ce que c'est...
ScheduleTable::update();
/*
* More complex example of the use of the ScheduleTable library
*
* This example uses 2 ScheduleTable with 3 actions each.
* Each schedule table manages a traffic light.
*
* Each traffic light has a 30s period.
* - Green light lasts for 13s
* - Yellow light lasts for 2s
* - Red light lasts for 15s
* Schedule tables are shifted so that one light switches from
* red to green when the other one shift from yellow to red.
*/
#include <ScheduleTable.h>
/* Both light cycle has 3 actions, lasts 30 time unit and has a 1000ms time base */
ScheduleTable firstLightCycle(3,30,1000);
ScheduleTable secondLightCycle(3,30,1000);
struct trafficLight {
byte greenPin;
byte yellowPin;
byte redPin;
};
const struct trafficLight firstLight = { 3, 4, 5 };
const struct trafficLight secondLight = { 6, 7, 8 };
enum { GREEN, YELLOW, RED };
void setLightState(const struct trafficLight& light, const byte state)
{
digitalWrite(light.greenPin, LOW);
digitalWrite(light.yellowPin, LOW);
digitalWrite(light.redPin, LOW);
switch (state) {
case GREEN: digitalWrite(light.greenPin, HIGH); break;
case YELLOW: digitalWrite(light.yellowPin, HIGH); break;
case RED: digitalWrite(light.redPin, HIGH); break;
}
}
void firstLightGreen() { setLightState(firstLight, GREEN); }
void firstLightYellow() { setLightState(firstLight, YELLOW); }
void firstLightRed() { setLightState(firstLight, RED); }
void secondLightGreen() { setLightState(secondLight, GREEN); }
void secondLightYellow() { setLightState(secondLight, YELLOW); }
void secondLightRed() { setLightState(secondLight, RED); }
void setup()
{
pinMode(firstLight.greenPin, OUTPUT);
pinMode(firstLight.yellowPin, OUTPUT);
pinMode(firstLight.redPin, OUTPUT);
pinMode(secondLight.greenPin, OUTPUT);
pinMode(secondLight.yellowPin, OUTPUT);
pinMode(secondLight.redPin, OUTPUT);
/* Green at start for first light */
firstLightGreen();
/* at 13s first light switches to yellow */
firstLightCycle.at(13,firstLightYellow);
/* at 15s, it switches to red */
firstLightCycle.at(15,firstLightRed);
/* at 30s, it switches back to green */
firstLightCycle.at(30,firstLightGreen);
/* Red at start for second light */
secondLightRed();
/* at 15s, it switches to green */
secondLightCycle.at(15,secondLightGreen);
/* at 28s, it switches to yellow */
secondLightCycle.at(28,secondLightYellow);
/* at 30s, it switches to red */
secondLightCycle.at(30,secondLightRed);
/* starts both light forever */
firstLightCycle.start();
secondLightCycle.start();
}
void loop()
{
/* update all the schedule tables at once */
ScheduleTable::update();
}
/*
* A third complex example of the use of the ScheduleTable library
*
* This example uses 3 ScheduleTable with 4 actions for the first one
* and 1 action of the other two.
*
* The first schedule table manages the whole cyle with:
* - a first action to start led dimming from 0 to 255
* - a second action to start led dimming from 255 to 0
* - a third action identical to the first one to start led dimming from 0 to 255
* - a fourth action to start led dimming from 255 to 0 at faster pace
*
* The sketch is supposed to do the cycle in 24h but the execution is sped 1000 times
* To change the speed, change the time base of each schedule table.
*/
#include <ScheduleTable.h>
/*
* The Green LED cycles.
*/
/* 4 actions, period duration in seconds = 24h */
ScheduleTable greenLEDCycle(4,86400);
/* 1 action, period duration = 7200 / 255 = 28 */
ScheduleTable greenLEDPWMIncreaseCycle(1,28);
/* 1 action, period duration = 10800 / 255 = 42 */
ScheduleTable greenLEDPWMDecreaseCycle(1,42);
byte pwmGreenLED = 0;
byte pinGreenLED = 3;
/*
* This function is called to start the increase of the PWM
*/
void startPWMIncrease()
{
/* start the schedule table for 255 periods */
greenLEDPWMIncreaseCycle.start(255);
}
/*
* This function is called to start the decrease of the PWM
*/
void startPWMDecreaseFast()
{
/* start the schedule table for 255 periods of 28s */
greenLEDPWMDecreaseCycle.setPeriod(28);
greenLEDPWMDecreaseCycle.start(255);
}
/*
* This function is called to start the decrease of the PWM
*/
void startPWMDecreaseSlow()
{
/* start the schedule table for 255 periods of 42s */
greenLEDPWMDecreaseCycle.setPeriod(42);
greenLEDPWMDecreaseCycle.start(255);
}
/*
* This function is called to increase the PWM of the green LED
*/
void increaseGreenLEDPWM()
{
pwmGreenLED++;
analogWrite(pinGreenLED, pwmGreenLED);
}
/*
* This function is called to decrease the PWM of the green LED
*/
void decreaseGreenLEDPWM()
{
pwmGreenLED--;
analogWrite(pinGreenLED, pwmGreenLED);
}
void setup() {
pinMode(pinGreenLED,OUTPUT);
pwmGreenLED = 0;
analogWrite(pinGreenLED,pwmGreenLED);
greenLEDCycle.at(27000,startPWMIncrease); /* at 7:30 */
greenLEDCycle.at(34200,startPWMDecreaseSlow); /* at 9:30 */
greenLEDCycle.at(63000,startPWMIncrease); /* at 17:30 */
greenLEDCycle.at(75600,startPWMDecreaseFast); /* at 21:00 */
greenLEDPWMIncreaseCycle.at(0,increaseGreenLEDPWM);
greenLEDPWMDecreaseCycle.at(0,decreaseGreenLEDPWM);
greenLEDCycle.start();
}
void loop() {
// put your main code here, to run repeatedly:
ScheduleTable::update();
}
ScheduleTable myTable(3, 200);
ScheduleTable myTable(3, 200, 100);
myTable.at(50, action1);
myTable.at(60, action2);
myTable.at(120, action3);
void action1()
{
Serial.print(millis());
Serial.println(" : action 1");
}
void action2()
{
Serial.print(millis());
Serial.println(" : action 2");
}
void action3()
{
Serial.print(millis());
Serial.println(" : action 3");
}
myTable.start()
myTable.update()
myTable.stop();