Show Posts
Pages: [1]
1  Forum 2005-2010 (read only) / Syntax & Programs / Re: How to something inside loop only once if... on: August 25, 2010, 03:10:11 am

Delay was after digitalWrite HIGH to brakePin, and then back to LOW.

Later it is very important to vary the brake time with potentiometer, in range of 0,05 to 1 second which I suppose to be enough.

Yes, brakePin goes low and high OK with that program, only it stays high forever when analogRead < 30 if throttle is not activated by turning the pot.

Also brake have to go "off" when throttle gets value more than 30, othervice some smoke near fets will be available more than I personally need ;-)

This may be done by writing brekpin low when throttle goes on.
2  Forum 2005-2010 (read only) / Syntax & Programs / How to something inside loop only once if... on: August 24, 2010, 02:37:08 pm

Pretty new to arduino. Tried search, not so brilliant in English.

Problem: I need to control motor, one direction only and regenerative? brake. Potentiometer to control speed and when to brake. Brake needs to be certain time on, and then it have to "let go".

Now speed control part of program works (very first easy test), but brake will not "let go". For test purposes I have only LED:s to see the output. Later when this works there will be FET:s and drivers for them.

I tried to use delay, but it didn't help.

So, the loop must be rolling all the time checking is there throttle or brake, and when braking, brakes should be "on" only once, certain time. And when throttle goes "on", brake must be off even thought there is brake time still going.

Later the brake will be also driven with pwm, here in test condition its enough to know it works or not...

Here is the code, which is not completely mine (some copy-paste and so on).


ps sorry about my bad english.

int ledPin = 9;      // LED connected to digital pin 9
int analogPin = 0;   // potentiometer connected to analog pin 3
int val = 0;         // variable to store the read value
int brakePin = 8;    // brake led
int state = 0;        // throttle or brake

void setup()
  pinMode(ledPin, OUTPUT);   // sets the pin as output
  pinMode(brakePin, OUTPUT); // sets the pin as output

void loop()
  val = analogRead(analogPin);   // read the input pin
  if (val > 30)
    state = 1;
    state = 0;
    switch (state) {
    case 0:
      digitalWrite(ledPin, LOW);
    digitalWrite(brakePin, HIGH);
    case 1:
    digitalWrite(brakePin, LOW);
        analogWrite(ledPin, val / 4);  // analogRead values go from 0 to 1023, analogWrite values from 0 to 255
3  Forum 2005-2010 (read only) / Scandinavia / Re: Suomalaisia on: August 20, 2010, 03:55:54 pm

Työkiireiden takia en ole vielä ehtinyt ottaa duemilanovea edes kokeiluun, mutta tarkotus olisi tässä puuhata sillä moottorin ohjaus regeneratiivisella säädettävällä jarrulla.

TIedän tarkkaan mitä haluan, en vaan osaa tehdä sitä (vielä) ;-)

Espoosta kajahtaa... tai no ainakin komeet savut jos (kun) tilttaa...

4  Forum 2005-2010 (read only) / Frequently-Asked Questions / Re: Measuring small (uA level) currents on: August 28, 2010, 08:17:34 am

Thank You very much!

never done anything with opamps, so one question about those: which value range will work best for R2? I suppose it to be less than 10 ohms, so please correct if I am completely out of range?

I may use 7 segment led display to tell uA:s to me, but that I have to google next week - seems to be lots of information I can study myself.

5  Forum 2005-2010 (read only) / Frequently-Asked Questions / Measuring small (uA level) currents on: August 28, 2010, 02:58:56 am

Any ideas how can I measure micro amperes with Arduino?

Range will be from 0,5 micro ampere to about 5 milliamperes, but mostly something between 1 and 5 uA.

Voltage from 0.7 to 2 volts, variable and easily controlled by user via potentiometer or something like that.

Probably linear regulator to control the voltage, because target is to measure quartz movement of a wristwatc: smallest amount of voltage which will run it, and current consumption to see the condition of movement.

Pages: [1]