Show Posts
|
|
Pages: [1] 2 3 ... 19
|
|
2
|
Community / Bar Sport / Bionic Man suit
|
on: March 11, 2013, 03:58:50 pm
|
I saw on the news today they have an exoskeleton device that is letting wheelchair bound people walk. I'm not sure how disabled the person they are testing is as far as nerve and muscle function. Its currently not for sale, and the story was half about the taxes on medical devices... What caught my eye was the price tag on this thing. Supposedly its 60k in parts alone. Meaning it will cost 1mil to the insurance company that buys it for you. I dont see it. The most badass tiny servos cant cost that much. i have a servo from servocity that will rip your fingers off for under $300. The plastic holding it together isnt 60k worth even if it was all carbon fiber. Obvioulsy there is a ton of research that went into it but they are saying this is just the hardware cost. After seeing the Arduino Segway I think you guys can build anything. This device doesnt seem to use brain waves or whatever for control, it uses the same tech as when you move your cell phone and the screen flips sideways, so a gyro of some sort. This is why i was questioning how disabled the person is to begin with as it looks like they have to start the movement meaning there must be some nerve/muscle function already. so what do you think this device "should" cost? Hardware only. http://video.foxnews.com/v/2219122650001/?playlist_id=929831913001i hate video links but this was all i found quickly.
|
|
|
|
|
3
|
Using Arduino / Programming Questions / Re: Button logic
|
on: November 08, 2012, 04:34:34 pm
|
bah my dreams are dashed  I spent a few minutes thinking about using a switch but it wont work like I want anyway. So on to debouncing. That first article referenced above is about 200 level stuff and I'm still taking the intro classes but I'll slog on and figure it out like I usually do.
|
|
|
|
|
4
|
Using Arduino / Programming Questions / Re: Button logic
|
on: November 08, 2012, 04:06:33 pm
|
thanks for the comments guys. Ill digest and do some more research and see what I come up with. Wow never new something as seemingly simple as a button could cause so much grief regarding bouncing. Maybe I should just put in a switch and be done with it. But where would the fun be there ? 
|
|
|
|
|
5
|
Using Arduino / Programming Questions / Re: Button logic
|
on: November 08, 2012, 05:48:27 am
|
|
ok i need to step back and verify i know what this part of the code is actually doing. This is my first time using interupts. That whole part of the code just came from the demo sketch with the device. Then I frankensteined the rest on.
rpm() just takes the variable NbTopsFan and increments it by one.
NbTopsFan is a Volatile variable so it gets saved to ram since it can be changed outside the part of the code its in.
attachInterrupt(0, rpm, RISING); I think this means that when it detects an rising interrupt on Pin 2 to run rpm() which then increments NbTopsFan.
so what i think is happening is the interrupt is enabled it waits for 1 second when the interrupt is enabled rpm() is called and NbTopsFan starts being incremented. Im fuzzy on what it is actually counting based on the RISING. the interrupt is disabled calculation to get flow display flow on lcd
a problem i see with this method is that I think all timing including millis and delay dont work properly when interrupts are disabled. this doesnt really matter if all the program is doing is looping and displaying the flow. But it does affect me since I do have other stuff happening in the sketch and once i disable the interrupts that stuff starts acting funny, in laymans terms.
So I suppose the question I should be asking is whats the best way to count the RISING without disabling interrupts as part of the process. Or how do I reenable interrupts without calling rpm(). Or maybe I should be trying to do it without ever disabling the interrupts.
Am I heading down the right rabbit hole now?
|
|
|
|
|
6
|
Using Arduino / Programming Questions / Re: Button logic
|
on: November 07, 2012, 01:52:24 am
|
Paul sometimes your little comments are enough to get the brain going in the right direction without giving away the answer. This is not one of those times... I tried removing the delay from what I think is the interupt. It stopped working. It currently works with the one delay but the buttons are still erratic. this is what I tried instead of using a delay. void checkflow() {
NbTopsFan = 0; //Set NbTops to 0 ready for calculations sei(); //Enables interrupts unsigned long currentMillis = millis(); //delay(1000); if(currentMillis - previousMillis > interval) { // save the last time you blinked the LED previousMillis = currentMillis; cli(); //Disable interrupts // block-style blinking cursor lcd.cursor(0); lcd.cursorTo(1,1); Calc = (NbTopsFan * 60 / 7.5); //(Pulse frequency x 60) / 7.5Q, = flow rate in L/hour lcd.print (Calc, DEC); //Prints the number calculated above lcd.print (" L/hour"); //Prints "L/hour" and returns a new line } lcd.cursorTo(2,1);
totaldispensed +=((float)Calc / 3600); lcd.print ("total: ");
int intValue = (int)totaldispensed; // convert float PHValue to tricky int combination float diffValue = totaldispensed - (float)intValue; int anotherIntValue = (int)(diffValue * 1000.0);
lcd.print (intValue); lcd.print ("."); lcd.print (anotherIntValue); lcd.print ("L");
} I didnt get any compile errors but it stopped counting. What should i be looking at to rid myself of the last delay and to start figuring out why button presses sometimes skip around and sometimes have to hold the button down for a while to get it to recognize the press.
|
|
|
|
|
7
|
Using Arduino / Programming Questions / Re: Button logic
|
on: November 03, 2012, 07:07:13 am
|
hey just removing all the delays and cleaning things up seems to have helped a bunch. my button presses seem to be recognized better now too. i dont have to hold the buttons down so long. still a little erratic ill keep working on it. my checkflow function seems to be working again as well.  I removed all the delays except in the interupt. ill try removing that one next. I also fixed some places that were clearing the lcd and making it blink really fast. // reading liquid flow rate using Seeeduino and Water Flow Sensor from Seeedstudio.com // Code adapted by Charles Gantt from PC Fan RPM code written by Crenn @thebestcasescenario.com // http:/themakersworkbench.com http://thebestcasescenario.com http://seeedstudio.com #include "SparkSoftLCD.h" #define LCD_TX 3 SparkSoftLCD lcd = SparkSoftLCD(LCD_TX); int incomingByte = -1; int val = 0; char code[10]; int bytesread = 0; volatile int NbTopsFan; //measuring the rising edges of the signal int Calc; int hallsensor = 2; //The pin location of the sensor float totaldispensed; int newdevicemode = 0; int devicemode = 0; int devicemodebuttonstate; int devicemodebuttonpin = 4; int devicemodelastButtonState = 0;
int stopgobutton; int stopgobuttonstate; int stopgobuttonpin = 5; int stopgolastButtonState = 0;
int autofillamount = 0;
int amigoing = 0;
int potPin = 1; int potval = 0;
long previousMillis = 0; long interval = 1000; void rpm () //This is the function that the interupt calls { NbTopsFan++; //This function measures the rising and falling edge of the hall effect sensors signal } // The setup() method runs once, when the sketch starts void setup() // { pinMode(hallsensor, INPUT); //initializes digital pin 2 as an input Serial.begin(9600); //This is the setup function where the serial port is initialised, attachInterrupt(0, rpm, RISING); //and the interrupt is attached
// setup lcd
pinMode(LCD_TX, OUTPUT); lcd.begin(9600); lcd.clear(); Serial.begin(9600); // hidden cursor lcd.cursor(0); } // the loop() method runs over and over again, // as long as the Arduino has power void loop () { unsigned long currentMillis = millis(); checkbuttons(); if (amigoing==1){ if (devicemode==2) { autofill(); } if (devicemode==1){ checkflow(); } } else { if (devicemode == 0) { lcd.cursorTo(1,1); lcd.print ("Waiting ");
} if (devicemode == 1) { if (amigoing != 1){ lcd.cursorTo(1,1); lcd.print ("Counter Mode"); } } if (devicemode == 2) {
lcd.cursorTo(1,1); lcd.print ("Autofill Mode"); lcd.cursorTo(2,1); lcd.print (autofillamount); } } } void checkbuttons() {
devicemodebuttonstate = digitalRead(devicemodebuttonpin);
// compare the buttonState to its previous state
if (devicemodebuttonstate != devicemodelastButtonState) {
// if the state has changed, increment the counter
if (devicemodebuttonstate == HIGH)
{ if (devicemode == 0){ newdevicemode = 1; lcd.clear(); lcd.print ("Counter Mode"); autofillamount = 0;
} if (devicemode == 1) { newdevicemode = 2; lcd.clear(); lcd.print ("AutoFill Mode"); autofillamount = 0;
} if (devicemode == 2) { newdevicemode = 0; lcd.clear(); lcd.print ("Turning Off"); lcd.clear(); autofillamount = 0; } devicemode = newdevicemode;
}
}
stopgobuttonstate = digitalRead(stopgobuttonpin); if (stopgobuttonstate != stopgolastButtonState) {
// if the state has changed, do something
if (stopgobuttonstate == HIGH) { if (amigoing == 0) {
if (devicemode == 1) { amigoing = 1; checkflow(); } if (devicemode == 2) { amigoing = 1; autofill(); }
}
else { amigoing = 0; devicemode = 0; lcd.clear();
} }
} // save the current state as the last state, //for next time through the loop stopgolastButtonState = stopgobuttonstate;
// read the pot to get fill amount: potval = analogRead(potPin); //map fill to 200 gallon max autofillamount = map(potval, 0,1023,1,200); }
void autofill(){
lcd.cursorTo(1,1); lcd.print ("Filling to: "); lcd.cursorTo(2,1); lcd.print (autofillamount);
}
void checkflow() {
NbTopsFan = 0; //Set NbTops to 0 ready for calculations sei(); //Enables interrupts delay (1000); //Wait 1 second cli(); //Disable interrupts lcd.clear();
// block-style blinking cursor lcd.cursor(0);
Calc = (NbTopsFan * 60 / 7.5); //(Pulse frequency x 60) / 7.5Q, = flow rate in L/hour lcd.print (Calc, DEC); //Prints the number calculated above lcd.print (" L/hour"); //Prints "L/hour" and returns a new line lcd.cursorTo(2,1);
totaldispensed +=((float)Calc / 3600); lcd.print ("total: ");
int intValue = (int)totaldispensed; // convert float PHValue to tricky int combination float diffValue = totaldispensed - (float)intValue; int anotherIntValue = (int)(diffValue * 1000.0);
lcd.print (intValue); lcd.print ("."); lcd.print (anotherIntValue); lcd.print ("L");
}
|
|
|
|
|
9
|
Using Arduino / Programming Questions / Button logic
|
on: November 02, 2012, 01:20:48 pm
|
I'm having trouble using buttons in my sketch. This is my first attempt at using them for anything other than turning on an led. The problem im having is the loop messing with my brain. pretty simple setup. 2 buttons. Mode Button to change modes. StopGo button to start or stop whatever mode you selected. And a pot to set the level for one of the modes. I'm currently able to select my mode and start it but that's where things start to fall apart. I feel like I need a bunch of If/Else statements to keep things flowing properly when it loops. Is that the way its usually done? I searched but found mainly simple press the button to turn on the led or huge menu systems I couldn't quite wrap my head around. One other issue is my checkflow function doesnt work. When i run it in a standalone sketch it works fine. I suspect the way its looping is off. It would be great if somebody can take a quick look at my sketch and tell me anything obviously wrong and/or if I'm even heading in the right direction. thanks // reading liquid flow rate using Seeeduino and Water Flow Sensor from Seeedstudio.com // Code adapted by Charles Gantt from PC Fan RPM code written by Crenn @thebestcasescenario.com // http:/themakersworkbench.com http://thebestcasescenario.com http://seeedstudio.com #include "SparkSoftLCD.h" #define LCD_TX 3 SparkSoftLCD lcd = SparkSoftLCD(LCD_TX); int incomingByte = -1; int val = 0; char code[10]; int bytesread = 0; volatile int NbTopsFan; //measuring the rising edges of the signal int Calc; int hallsensor = 2; //The pin location of the sensor float totaldispensed; int newdevicemode = 0; int devicemode = 0; int devicemodebuttonstate; int devicemodebuttonpin = 4; int devicemodelastButtonState = 0;
int stopgobutton; int stopgobuttonstate; int stopgobuttonpin = 5; int stopgolastButtonState = 0;
int autofillamount = 0;
int amigoing = 0;
int potPin = 1; int potval = 0;
void rpm () //This is the function that the interupt calls { NbTopsFan++; //This function measures the rising and falling edge of the hall effect sensors signal } // The setup() method runs once, when the sketch starts void setup() // { pinMode(hallsensor, INPUT); //initializes digital pin 2 as an input Serial.begin(9600); //This is the setup function where the serial port is initialised, attachInterrupt(0, rpm, RISING); //and the interrupt is attached
// setup lcd
pinMode(LCD_TX, OUTPUT); lcd.begin(9600); lcd.clear(); Serial.begin(9600); // hidden cursor lcd.cursor(0); } // the loop() method runs over and over again, // as long as the Arduino has power void loop () {
checkbuttons(); if (amigoing==1){ if (devicemode==2) { autofill(); } if (devicemode==1){ checkflow(); } }
} void checkbuttons() {
if (devicemode == 0) { lcd.clear(); lcd.print ("Waiting for your "); lcd.cursorTo(2,1); lcd.print ("command sir..."); } if (devicemode == 1) { // lcd.clear(); if (amigoing != 1){ lcd.cursorTo(1,1); lcd.print ("Counter Mode"); }} if (devicemode == 2) { // lcd.clear(); lcd.cursorTo(1,1); lcd.print ("Autofill Mode"); lcd.cursorTo(2,1); lcd.print (autofillamount); } delay (500); devicemodebuttonstate = digitalRead(devicemodebuttonpin);
// compare the buttonState to its previous state
if (devicemodebuttonstate != devicemodelastButtonState) {
// if the state has changed, increment the counter
if (devicemodebuttonstate == HIGH)
{ if (devicemode == 0){ newdevicemode = 1; lcd.clear(); lcd.print ("Counter Mode"); delay (500); autofillamount = 0; // checkflow(); } if (devicemode == 1) { newdevicemode = 2; lcd.clear(); lcd.print ("AutoFill Mode"); delay (500); autofillamount = 0; // autofill(); } if (devicemode == 2) { newdevicemode = 0; lcd.clear(); lcd.print ("Turning Off"); delay (500); lcd.clear(); autofillamount = 0; } devicemode = newdevicemode;
}
delay(50);
}
stopgobuttonstate = digitalRead(stopgobuttonpin); if (stopgobuttonstate != stopgolastButtonState) {
// if the state has changed, do something
if (stopgobuttonstate == HIGH) { if (amigoing == 0) {
if (devicemode == 1) { lcd.clear(); lcd.print ("going to checkflow"); lcd.cursorTo(2,1); amigoing = 1; delay (5000); checkflow(); } if (devicemode == 2) { lcd.cursorTo(1,1); lcd.print ("AutoFill Amount"); lcd.cursorTo(2,1); lcd.print (autofillamount); amigoing = 1; autofill(); }
}
else { amigoing = 0;
} }
delay(50);
} // save the current state as the last state, //for next time through the loop stopgolastButtonState = stopgobuttonstate;
// read the pot to get fill amount: potval = analogRead(potPin); //map fill to 200 gallon max autofillamount = map(potval, 0,1023,1,200); }
void autofill(){ // lcd.print("blah"); // delay(5000); lcd.cursorTo(1,1); lcd.print ("Filling to:"); lcd.cursorTo(2,1); lcd.print (autofillamount);
}
void checkflow() { //lcd.print("counting"); // delay(5000);
NbTopsFan = 0; //Set NbTops to 0 ready for calculations sei(); //Enables interrupts delay (1000); //Wait 1 second cli(); //Disable interrupts lcd.clear(); /// lcd.print("counting123"); // delay(5000);
// block-style blinking cursor lcd.cursor(0);
Calc = (NbTopsFan * 60 / 7.5); //(Pulse frequency x 60) / 7.5Q, = flow rate in L/hour lcd.print (Calc, DEC); //Prints the number calculated above lcd.print (" L/hour"); //Prints "L/hour" and returns a new line lcd.cursorTo(2,1);
totaldispensed +=((float)Calc / 3600); lcd.print ("total: "); delay(5000);
int intValue = (int)totaldispensed; // convert float PHValue to tricky int combination float diffValue = totaldispensed - (float)intValue; int anotherIntValue = (int)(diffValue * 1000.0);
lcd.print (intValue); lcd.print ("."); lcd.print (anotherIntValue); lcd.print ("L"); delay(5000); }
|
|
|
|
|
10
|
Using Arduino / Project Guidance / Re: Running Total calculated from flow rate
|
on: October 27, 2012, 02:39:29 pm
|
when integrating the sum values become larger and you might consider using unsigned longs for
volatile int NbTopsFan; //measuring the rising edges of the signal
An int wraps at 32767 pulses An unsigned int at 65535 An unsigned long at 4 billion++ pulses
An unsigned long has 10 digits of precision where floats have around 7 d.o.p.
probably why when I got home from dinner the total had creeped up even though there was no flow. Ill give your way a shot. thanks!
|
|
|
|
|
11
|
Using Arduino / Project Guidance / Re: Running Total calculated from flow rate
|
on: October 26, 2012, 08:22:27 pm
|
To get the total amount you need to integrate the flow rate over time.
Measure the flow rate. Measure the elapsed time since the previous flow measurement.Multiple the flow rate by the elapsed time to get the amount that flowed in that time interval. Add that to your running total.
You want the measurement interval to be relatively small, but not so small that the resolution of your time measurement or flow rate measurement become significant. Sampling once a second would probably be reasonable. Sampling once a millisecond or once a minute probably wouldn't.
Yup its sampling using a 1 second interrupt and looping and im including the total in the loop. nothing else is happening in the loop other than the display. Now what I dont know is if I add a bunch of "stuff" that happens outside the 1 second interrupt how badly ill start drifting from accurate. My only other plans are to add button presses and a relay. So you can for example enter 20 and hit go and it turns on a pump for 20L.
|
|
|
|
|
12
|
Using Arduino / Project Guidance / Re: Running Total calculated from flow rate
|
on: October 26, 2012, 08:18:25 pm
|
Well this seems to work. I need to hook it up to a pump and see if the values are anywhere near accurate. This keeps a running total and displays it on a sparkfun LCD // reading liquid flow rate using Seeeduino and Water Flow Sensor from Seeedstudio.com // Code adapted by Charles Gantt from PC Fan RPM code written by Crenn @thebestcasescenario.com // http:/themakersworkbench.com http://thebestcasescenario.com http://seeedstudio.com #include "SparkSoftLCD.h" #define LCD_TX 3 SparkSoftLCD lcd = SparkSoftLCD(LCD_TX); int incomingByte = -1; int val = 0; char code[10]; int bytesread = 0; volatile int NbTopsFan; //measuring the rising edges of the signal int Calc; int hallsensor = 2; //The pin location of the sensor float totaldispensed; void rpm () //This is the function that the interupt calls { NbTopsFan++; //This function measures the rising and falling edge of the hall effect sensors signal } // The setup() method runs once, when the sketch starts void setup() // { pinMode(hallsensor, INPUT); //initializes digital pin 2 as an input Serial.begin(9600); //This is the setup function where the serial port is initialised, attachInterrupt(0, rpm, RISING); //and the interrupt is attached
// setup lcd pinMode(LCD_TX, OUTPUT); lcd.begin(9600); lcd.clear(); Serial.begin(9600); // hidden cursor lcd.cursor(0); } // the loop() method runs over and over again, // as long as the Arduino has power void loop () { NbTopsFan = 0; //Set NbTops to 0 ready for calculations sei(); //Enables interrupts delay (1000); //Wait 1 second cli(); //Disable interrupts lcd.clear(); // block-style blinking cursor lcd.cursor(0); Calc = (NbTopsFan * 60 / 7.5); //(Pulse frequency x 60) / 7.5Q, = flow rate in L/hour lcd.print (Calc, DEC); //Prints the number calculated above lcd.print (" L/hour"); //Prints "L/hour" and returns a new line lcd.cursorTo(2,1); totaldispensed +=((float)Calc / 3600); lcd.print ("total: "); int intValue = (int)totaldispensed; // convert float PHValue to tricky int combination float diffValue = totaldispensed - (float)intValue; int anotherIntValue = (int)(diffValue * 1000.0); lcd.print (intValue); lcd.print ("."); lcd.print (anotherIntValue); lcd.print ("L"); }
|
|
|
|
|
13
|
Using Arduino / Project Guidance / Re: Running Total calculated from flow rate
|
on: October 26, 2012, 06:59:48 pm
|
hmm some more thinking and I came up with this: totaldispensed += (Calc / 3600); Serial.print ("total dispensed: "); Serial.println (totaldispensed); code doesnt work but I think the field types are different or something so I have to deal with that. any better ideas welcome.
|
|
|
|
|
14
|
Using Arduino / Project Guidance / Running Total calculated from flow rate
|
on: October 26, 2012, 06:34:42 pm
|
I have a sensor that will tell me the flow rate of a liquid using a hall effect sensor and propeller. I'd like to also display the total liquid "processed". I thought of simply keeping time and dividing it by the flow rate. The problem is if the flow rate is constantly changing that wont be accurate. Any thoughts on how to attack this? heres the current code. // reading liquid flow rate using Seeeduino and Water Flow Sensor from Seeedstudio.com // Code adapted by Charles Gantt from PC Fan RPM code written by Crenn @thebestcasescenario.com // http:/themakersworkbench.com http://thebestcasescenario.com http://seeedstudio.com
volatile int NbTopsFan; //measuring the rising edges of the signal int Calc; int hallsensor = 2; //The pin location of the sensor
void rpm () //This is the function that the interupt calls { NbTopsFan++; //This function measures the rising and falling edge of the hall effect sensors signal } // The setup() method runs once, when the sketch starts void setup() // { pinMode(hallsensor, INPUT); //initializes digital pin 2 as an input Serial.begin(9600); //This is the setup function where the serial port is initialised, attachInterrupt(0, rpm, RISING); //and the interrupt is attached } // the loop() method runs over and over again, // as long as the Arduino has power void loop () { NbTopsFan = 0; //Set NbTops to 0 ready for calculations sei(); //Enables interrupts delay (1000); //Wait 1 second cli(); //Disable interrupts Calc = (NbTopsFan * 60 / 7.5); //(Pulse frequency x 60) / 7.5Q, = flow rate in L/hour Serial.print (Calc, DEC); //Prints the number calculated above Serial.print (" L/hour\r\n"); //Prints "L/hour" and returns a new line } using this sensor: http://www.seeedstudio.com/depot/g12-water-flow-sensor-p-635.html?cPath=144_151
|
|
|
|
|