Show Posts
Pages: 1 ... 48 49 [50] 51 52 ... 87
736  Using Arduino / Programming Questions / Re: Stepper motor repeat/interupt code on: April 23, 2012, 05:51:11 am
Switches...
Code:
if (mode ==0 && digitalRead(setupAswitch) == LOW){ mode = 1;}
will read the reed smiley and only switch into mode 1, from the startup state. Nice code. That part works. And it will not be confused with button bounce.
Code:
case 1:  // Set Stepper start position A
//Rotate until reed switchA is LOW
mode = 3;
break;
I presume that is a place holder for now, 'cause mode 3 does nothing, exect allow us to move onto mode 4&5 on the next pass of the loop. (approx 10-odd microseconds later.)

Similar to the case 4, we test the condition for leaving mode 1, and if not do something in mode 1. (I really want you to find the solution yourself smiley )

The test will be digitalRead(reedswitchA), and on to mode 3 else do a Stepper.step and delay a while. (if it is +1 or -1 is your choice)
737  Using Arduino / Programming Questions / Re: Stepper motor repeat/interupt code on: April 22, 2012, 12:10:52 pm
The solution depends on if you need to run loop() during the initial sequence (f.ex. to blink a LED, move another motor or check a temperature meter)

If you only need to do this motion then something like
Code:
case 4: // Run Stepper Prog A
 for ( int c=0; i<500; i++) {
   myStepper.step(1);
   delay(6000);
   }
mode = 6;
break;
would work BUT this means that the machine does nothing else for 50 minutes.

If you need to monitor - fex. an quick stop switch - then

Define variable CountA, set it to 0

In case 4 fix the last line to be
  if ( CountA++ >500 ) mode = 6 ;

This way the code will (as long as the first 4 lines do not change it) repeatedly do case 4 for each loop() pass, until it has executed 500 times.
738  Using Arduino / Motors, Mechanics, and Power / Re: Power supply on: April 20, 2012, 12:12:39 pm
$200 for the controller -  smiley-eek

Ehr ... apart from the Voltage/current which fit, was it something particular you were worried about?

I would think it was harder to specification-match that controller to the steppers you have.
739  International / Deutsch / Re: 2 Stepper per Joystick steuern on: April 20, 2012, 12:02:36 pm
Das beispiel unter Exmaple Steppers MotorKnob tut es. Ein pot ein Stepper. Brauchts bloss den kode vier-faltig einlegen ...
740  Community / Bar Sport / Re: Raspberry 3.14159265.... a first review on: April 20, 2012, 11:54:36 am
... people do not regard the UK as Europe, in the rest of Europe as well as in the UK. Why we are in the EU I will never know, it is all down to the Germans wanting revenge for loosing the war.
No it was the French who needed someone to pay for their ridiculuos farmer subsidies. smiley

signed one who has lived 10 years in UK, 6 years in DE and 10 years in SE and quite a lot in DK not in that order ...
741  Using Arduino / LEDs and Multiplexing / Re: RGB led controlled by Matlab without using official matlab script on: April 17, 2012, 03:13:58 pm
I do not know of MATLAB, so I do not know what happens when you use fwrite() and send a value greater than 256. It either truncates it down to 256, sends the value modulus-256 or it sends several bytes. You need to know which.

Your problem is that Serial.read() will alwys only read a single byte at a time. Just like your keyboard only sends one key at a time, and you compose words by several keys in sequence and finish with a space, so you need to send your LED commands as several bytes.

I suggest you send three bytes. The first byte is the LED1 value, the 2nd byte is the LED2 value and the 3rd byte is 255.

In your send code you never send 255 as the value. In your receive code, if the 1st or 2nd byte is 255, then you know you have "lost a byte somewhere" and your code should start waiting for byte 1 again.

That is what is called a "protocol", ie the rules how the bytes are interpreted, and how to handle some errors. There are many ways to define a protocol, my suggestion is just a simple variant that fits the approach you have in your code.
742  Using Arduino / LEDs and Multiplexing / Re: LED with wave shield on: April 11, 2012, 06:04:46 pm
"I made a wave shield". There are more than one supplier and layout out there ...

but I wont bother you anymore.
743  Using Arduino / Project Guidance / Re: Temperature Sensing and logging on EEPROM - GUIDANCE!!! on: April 11, 2012, 06:02:33 pm
Am I splitting the float value into two bytes, and storing at two different addresses, or at the same address??
Two addresses. My brief (and quickly typed) example thus has an error  smiley-sad-blue it should be
Code:
EEPROM.write(addr++, celcius) ; // by sheer conicidence, if your temperatur is within +/-127
                      //  it will write the integer part
EEPROM.write(int(addr++, celcius*100)/100-int(celcius)*100);
// ommit the addr = addr + 1
// - the addr value has already been advanced by 2
744  International / Scandinavia / Re: Styring av Servo (robot) on: April 11, 2012, 05:35:09 pm
Yep. Kig på Servo eksemplerne i Arduino IDE (File, Examples ...)

En servo skal have en digital pulse hver 20 millisekund. Pulsens bredde er mellem 1,5 til 0,7 milliskund bred (hvos jeg nu husker rigtigt). Bredden af pulsen afgør hvilken position servoen tager.

Servo library sørger for alt det - du siger bare hvilken pin der skal bruges, og så skriver du et tal mellem 0 til 180. Det er så vinklen den drejer.

Rød er plus og sort er minus og omvendt er en styg kortslutning - som du opdagede smiley
745  Using Arduino / Project Guidance / Re: difference between reboot and reset on: April 11, 2012, 05:30:06 pm
As far as I know they should be the same. Usually it is the other way round - a power cycle is more thorough that a button reset.

The AVR chip should do an internal reset until power is stable and the oscillator is running. I can imagine that your board due to variance of components and your way of supplying/loading power is such that the chip "starts too early".

Bad power may also explain your other sudden stops.  (and there is always the possibility that you have a real hardware fault on your board, akin to a loose connection - unlikely, though)
746  Using Arduino / Project Guidance / Re: Temperature Sensing and logging on EEPROM - GUIDANCE!!! on: April 11, 2012, 05:18:20 pm
You write a BYTE at a time. That is an interer between 0 and 255. Or, if you choose to interpret it signed between -128 and +127. Or a character with all A-Z, a-z, funny characters and controlchars (dont get me started on character sets)

Now, your temperature is a float number. That (usually) consists of 4 bytes and goes from - several billion to plus several billions in tinsy increments of a fraction of a fraction... (lets not get into discussion of precision and number of significant digits of floats)

The easy way: You can convert your temperature (going by your example numbers) into two bytes that represent the whole and fractional part
Code:
EEPROM.write(addr, celcius) ; // by sheer conicidence, if your temperatur is within +/-127
                      //  it will write the integer part
EEPROM.write(int(addr, celcius*100)/100-int(celcius)*100);
The easy way assumes that the whole and fractional part both are "two digits". (loosly speaking)

The better way is to use some C-trickry to get at the 4 bytes.
Code:
void EPW(float f) { // write a float in 4 consecutive "addr" locations
  byte * b = (byte *) &f;
  EEPROM.write(addr++, b[0]);
  EEPROM.write(addr++, b[1]);
  EEPROM.write(addr++, b[2]);
  EEPROM.write(addr++, b[3]);
  // at the end addr has advanced 4
}
I found a few referneces, but no cut-n-ready solution, but I am sure someone has made a library for this. (And I can't be bothered to write one right now smiley )
747  Using Arduino / LEDs and Multiplexing / Re: LED with wave shield on: April 11, 2012, 04:11:29 pm
Yes, well, your explanation does not give me a clue what shield you have made. No picture, schematic or specification. So how would I or others know if there is room for a LED?

Hrrmphph.... smiley-evil
748  Using Arduino / LEDs and Multiplexing / Re: LED with wave shield on: April 11, 2012, 12:26:50 pm
Could you turn the shield a little more to the left? I can not see the sockets clearly ....
 smiley-roll-blue
749  Using Arduino / LEDs and Multiplexing / Re: loops on: April 11, 2012, 12:18:32 pm
My example included a number in the call of the function. You are missing it. That is what the error is saying. It also says it is on line 23. (You can see which line number is positioned on right at the bottom)

Why did I include a numeric argument? Well, it might have been usefull to pass a number, and this way you got that syntax. If you do not want to pass a number you must omit it both in the declaration and the call.

750  Using Arduino / LEDs and Multiplexing / Re: loops on: April 11, 2012, 08:52:07 am
Code:
// defining it:
void cmd_one( int number) {
// do something. You have the value in "number". You can not change it.
}

// using it
void loop() {
  cmd_one ( 5 ) ;
}
Pages: 1 ... 48 49 [50] 51 52 ... 87