Show Posts
Pages: 1 ... 44 45 [46] 47 48 ... 82
676  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.
677  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.
678  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
679  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
680  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)
681  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 )
682  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
683  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
684  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.

685  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 ) ;
}
686  Using Arduino / Project Guidance / Re: Temperature Sensing and logging on EEPROM - GUIDANCE!!! on: April 11, 2012, 03:54:46 am
Yes, "in principle"  smiley

When you remove the Arduino from where it was measuring to where you want to start listing measuremnets the measuring program will immedieatly start again when you apply power, and start overwriting the first set. So I suggest you put a wire between, say, GND and pin 12, and use the internal pullup resistor on pin12. The program tests on pin12 if this is a Measure&log session or a printout session. A jumper-switch in other words.
687  Using Arduino / Project Guidance / Re: Serial Communications Trigger on: April 11, 2012, 03:46:26 am
Thank you very much for the feedback. Good for the Forum, and really nice to know the suggestion made was usefull.
688  Using Arduino / Project Guidance / Re: Serial Communications Trigger on: April 10, 2012, 10:35:32 am
I do not know of a way you can "read" if the USB is connected or not, whether there is an appropiate program on the pc.

The screen shot shows PuTTY. Theres is a "enquiry" string you can send to PuTTY (and most other terminal emulators), and PuTTY will reply with some terminal info. If you do that in the Arduino in setup() you can then disable your serial debug/diagnstic routine.
689  Using Arduino / Interfacing w/ Software on the Computer / Re: Why does PuTTY hang my Duemilanove? on: April 09, 2012, 03:12:02 pm
Thanks, I may try that later.

I also may try and put a scope on some FTDI legs to try and guess what is happening. But may, just maybe, someone here already knows on an interpretetion of the control signals of the pseudo-COM port.
690  Using Arduino / Interfacing w/ Software on the Computer / Re: Why does PuTTY hang my Duemilanove? on: April 08, 2012, 01:53:24 pm
Eh? Not sure I follow your reasoning. If I use SoftSerial it will be on differnet pins and I have to use the USB/Serial adaptor cable. That is what I tried on the hardware lines (pin 0/1) and there it works fine as (unclearly?) described on earlier post. Putty & Serial monitor.

As far as switching hardware and everything my conclusion at this point is that it only fails if PuTTY is talking to that FTDI chip. And in some ways academic - the way I plug my Arduino into lots of experimental setups I am not surprised something breaks (it already is the 2nd chip on that board,  smiley-eek-blue I've blown the poly reset fuse 3 times, and the laptop has had a few emergency power saftey shutdowns, too  smiley-roll )

I have an old issue with my Mega not talking to Processing which smells of a similar problem (other programs talk fine with it, on others machine (OSversion) it works with Processing). This I am getting curious what is happening with the other control-lines ie DTR/CTS/DSR and so on.

(edit: added link to "old issue")
Pages: 1 ... 44 45 [46] 47 48 ... 82