Pages: 1 ... 3 4 [5]   Go Down
Author Topic: what input pin is it using?  (Read 3324 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Sr. Member
****
Karma: 0
Posts: 287
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

ok
if im using a hall sensor it is high or low
i no there will be 6 triggers a revolution
we no what short of speeds we are looking at
what else we looking at apart from the mechanical side?
Logged

Pittsburgh, PA, USA
Offline Offline
Faraday Member
**
Karma: 58
Posts: 3994
I learn a bit every time I visit the forum.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hall switch operates ON/OFF.

Hall sensor linear type is analog -but- digital read pin triggers ON/OFF when voltage passes the switch points so you can use the linear type either way.

6 triggers per revolution... not 60?
With 60 the triggers per second is same as rpm, with 6 it is rpm/10.

I think that you could get by polling all 3 sensors at once by Port read and process the 3 bits at 10,000, maybe more triggers per second continuous if you don't do heavy processing.

If you don't do continuous reads, say capture and store 100 to 500 reads in an array and then process those while not reading then you could capture higher rates, possibly over 50,000 triggers per second and still sample and control more than 10x a second.

My ultrasonic sensor code has a while loop that does a digital read, unsigned long increment and unsigned long compare that runs just about 1 million times a second. I am being conservative in my estimates above because I can't be sure what your processing entails.
Logged

Examples can be found in your IDE.

Pittsburgh, PA, USA
Offline Offline
Faraday Member
**
Karma: 58
Posts: 3994
I learn a bit every time I visit the forum.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

It does occur to me that you could write test programs reading the pins in a loop just to see how fast you can do it --- as long as the data doesn't matter. You can set them INPUT HIGH or pull them down through a 10k or higher (better) resistor or just let them float. Do all the things you would do with real data except run the car, you can get a good idea of what's possible.

Read all the pins at once for best results. Well, using AVR code in the sketch may save more cycles but I'm not the person to say those steps -- I do what I need without.

Logged

Examples can be found in your IDE.

0
Offline Offline
Sr. Member
****
Karma: 0
Posts: 287
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

yes the 60 trigger was with the old sensor i was thinkthing of putting the new sensor somewhere else hence now 6 trigger
here is the code i have at mo:
i no there is delays in it but when they are active the hall will not be being used
i would like to put all what we have been talking about in where it says (auto mod)

Code:


#include <AH_EasyDriver.h>

//AH_EasyDriver(int RES, int DIR, int STEP, int MS1, int MS2, int SLP);
AH_EasyDriver stepper(200,2,3,4,5,6);    // init w/o "enable" and "reset" functions


int tempsensor     = A1;
int brack          = 12;
int pump           = 13;
int automanual     = 11;
int overtempled    = 10;

int previous = 0;                       // the previous reading from the analog input
bool DoneInitialization = false;

void setup() {
  stepper.resetDriver();                  // reset driver
  stepper.enableDriver();                 // enable driver
  stepper.setMicrostepping(3);            // 0 -> Full Step                               
                                          // 1 -> 1/2 microstepping
                                          // 2 -> 1/4 microstepping
                                          // 3 -> 1/8 microstepping
  stepper.setSpeedRPM(50);                // set speed in RPM, rotations per minute
  pinMode(brack      , INPUT) ;           // brack
  pinMode(pump       , OUTPUT);           // hydraulis pump
  pinMode(automanual , INPUT) ;           // auto / manual swicth
  pinMode(overtempled, OUTPUT);           // over temp LED
  delay(4000);
}

void loop() {
                                            // get the sensor value
  int potVal = analogRead(0);
  int stpPos = map(potVal, 0, 1023, 0, 152);
  //                                         ----------------------
  int val = analogRead(tempsensor);          // temp sensor high
  if (val <970) {
    digitalWrite(pump,        HIGH);         // hydraulis pump high
    digitalWrite(overtempled,    LOW);          // over temp LED
    //                                      ----------------------- 
    if (digitalRead(brack) == LOW) {        // brack swicth
    if (digitalRead(automanual) == HIGH) {  // auto / manual swicth
    //                                    -------------------------------------------
        if (!DoneInitialization) {
    stepper.sleepON();                     // set Sleep mode ON
    delay(10000);
        DoneInitialization=true;           // Initialization is done, don't run it again until it has been reset
    } //                                ---------------------------------------------
      stepper.sleepOFF();                  // set Sleep mode OFF
      stepper.rotate(stpPos - previous);

      previous = stpPos;                   // remember the previous value of the sensor
    }
//                                      ---------------------------------------------
  else {                                              // -- AUTO mod -- //
                                                      //----------------//
  }
}
  //                                      ---------------------------------------------------------
  else {                                   // brack swicth when HIGH
      stepper.rotate(-previous);
                                           // reset the previous value to zero
      previous = 0;
  }
 }
  //                                      ---------------------------------------------------------
  else {                                   // temp sensor HIGH
    stepper.rotate(-previous);
    previous = 0;                          // reset the previous value to zero
    DoneInitialization=false;              // resetting the count
    digitalWrite(overtempled,    HIGH);    // over temp LED
    delay(1000);
    stepper.sleepON();                     // set Sleep mode ON
    delay(10000);
    digitalWrite(pump,          LOW);      // hydraulis pump high
    delay(30000);
  }
  //                                     --------------------------------------------     
}
Logged

Pittsburgh, PA, USA
Offline Offline
Faraday Member
**
Karma: 58
Posts: 3994
I learn a bit every time I visit the forum.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Oh no. You have to use timing based (Real Time) code to get this to work, even using interrupts.
The stepper moves like a glacier compared to Arduino. Loop has to finish very fast to get enough reads per second for... I forget how many rpm but it's for a car wheel.

If you read 10x as often as triggers then you will be sure to catch every one a few times in a row. That lets you be sure you don't get false positives, a good thing.

Also be real careful to debug and test this insanely much before going out on any road. If someone gets hurt there will be lawyers who will do anything to make it your fault. Facts won't matter, they are trained to steer around such trivialities as facts.


Logged

Examples can be found in your IDE.

Pages: 1 ... 3 4 [5]   Go Up
Jump to: