Show Posts
Pages: 1 [2] 3 4 ... 579
16  Using Arduino / Networking, Protocols, and Devices / Re: Communicate between microcontrollers: Automatic address and request-less send? on: April 13, 2014, 07:13:59 pm
Quote
Another option I thought of is to use the serial communication to communicate with each other. The RX is connected to the TX of the other controller and so on.
That would probably be my approach, I assume you are happy to use serial rather than I2C.

The only down side is determining the order in which buttons are pressed, for example if a button on node 2 is pressed just before one on node 22 the master will still see the press from 22 first.

Is this a problem with your application?  If it's a game where the first button pressed wins then maybe.

As for the addresses, you can have a simple self-discovery algorithm that sends 0 to the first node, it records that as it's address, increments the number and passes it along. When the number returns all nodes have a unique address and you also know how many there are.

Also what is the distance between these boxes, I2C is not normally good for long runs.

______
Rob
17  Using Arduino / Programming Questions / Re: Help with modulo. 25%10 always rounds off to 6. on: April 13, 2014, 06:53:37 pm
No that's ok, you can call functions from anywhere, loop() is already called from main() so every time you do (for example) a Serial.print() inside loop() you are already calling a function from inside a function, and for all you know Serial.print() calls 10 other functions all of which call other functions again.

Subject to the stack overflowing there is no limit.

It seems that erdiegange's code works for everyone else, so the only unknown is the updateDisplay() function.

______
Rob
18  Using Arduino / Project Guidance / Re: Nested interrupts using NOBLOCK on: April 13, 2014, 06:35:37 pm
Quote
Another thing that could be done is to move the parsing function outside the ISR...
That is the recommended method and the "party line" on this forum. I don't necessarily follow the party line because all situations are different and it can make sense to have a lot of code in an ISR, after all if there is nothing else to do why not?

Maybe you should look at your timing to see if it's worth the risk of enabling nested interrupts, if the data is coming in at 300 baud you have about a week and a half to parse the packet before the next character comes in anyway.

I have to say though that in this case I will follow the party line, I think the ISR should just add chars to a FIFO and the main code should take chars from that FIFO and parse as required. That is a simple and compartmentalised interface.

Quote
What about noblock and Priority handling?
I've never heard of noblock so can't comment on that. The priority of interrupts is as per their order shown in the data sheet, and as I said before if you enable interrupts in the ISR then they will be handled, but if you are both adding and removing bytes from a FIFO you have to be very careful about all non-atomic instructions that deal with global elements of the FIFO, head and tail pointers are probably OK in themselves but any operations that use both have to be protected and as do things like counters that hold the number of bytes in the FIFO.

As for malloc(), are all the blocks the same size? If so why not just have an array of arrays for the data? If not how will you free the blocks without getting fragmentation?

If you have a FIFO of pointers to arrays there is no need to move data around at all, in general you try to avoid physically moving bytes, it's better to change a pointer.

______
Rob

19  Using Arduino / Project Guidance / Re: Nested interrupts using NOBLOCK on: April 13, 2014, 08:51:32 am
On an AVR if you enable interrupts inside an ISR they will be handled when they occur according the their priority. As there is just a single flag controlling the interrupt enable ALL interrupts that occur will be handled, possibly even the one you are already handling if that occurs again.

______
Rob
20  Products / Arduino Due / Re: 5100 ethernet and Due on: April 13, 2014, 08:09:29 am
I think so, do you see a "remove" button?

______
Rob
21  Products / Arduino Due / Re: 5100 ethernet and Due on: April 13, 2014, 07:41:59 am
All those definitions (DDRB, PORTB etc) are AVR-specific, they will not work on a Due. More than that I can't say because I've not used those libs.

BTW, why two posts?

______
Rob
22  Using Arduino / Project Guidance / Re: Nested interrupts using NOBLOCK on: April 13, 2014, 07:38:51 am
We haven't see any code yet and also don't know what you are trying to achieve, but it's pretty hard to think of a good reason to use "malloc" and "nested interrupts" in the same sentence.

Can you explain what you are trying to achieve, not how you think it should be done.

______
Rob
23  Using Arduino / General Electronics / Re: Shift registers - only good for LEDs? on: April 13, 2014, 07:34:06 am
PWM through a shift reg is possible, pretty inefficient but if you are really short of pins ok.

Quote
I have seen projects driving high powered LEDs through 595s.
Not without further amplification, or not for very long.

Quote
Unfortunately, it still doesn't answer my question !
I thought everyone had, what was the question again then?

______
Rob
24  Using Arduino / General Electronics / Re: Digital output interface (0 and 1) on: April 13, 2014, 07:28:42 am
Quote
I was thrown for  bit by the Analog println loop where as the digital println did not seem to loop...
Yep, gets me every time that one.

______
Rob
25  Using Arduino / Project Guidance / Re: Multi-node CAN bus: a progress report on: April 13, 2014, 06:49:06 am
You've certainly done a lot of work, well done.

______
Rob
26  Using Arduino / Project Guidance / Re: Determining If Relays Are Working, Programmatically on: April 12, 2014, 07:16:00 pm
Quote
If one is 12Vdc and the 0V then there's a problem
Doh, don't mind me, I've only had 2 cups of coffee and aren't fully up to speed yet smiley

In fact I used an XOR gate to do almost this exact function (detect a blown fuse) just recently.

______
Rob
27  Using Arduino / Project Guidance / Re: Determining If Relays Are Working, Programmatically on: April 12, 2014, 07:06:32 pm
Quote
analog inputs on each side of the relays and make a comparison between In and Out. Can anyone see any problems with that
Yes, if you are talking about the coil it doesn't tell you much at all, and if you are talking about the contacts you would never read the voltage drop as it will be uV probably.

It will depend on exactly what you are switching, using a spare contact pair is the easiest way but that's still not 100% as the other contacts may have a fault.

What are you switching?

______
Rob
28  Using Arduino / Project Guidance / Re: Automatic plant watering system on: April 12, 2014, 08:23:26 am
From a famous movie "What we got here is... failure to communicate." Sorry I sometimes forget what it's like to be a beginner at this stuff.

Listen to PeterH smiley

______
Rob
29  Using Arduino / Project Guidance / Re: Automatic plant watering system on: April 12, 2014, 08:13:05 am
How can there be any confusion, one side is for the mains, the other for a 12v pump, what is there not to understand? It's not even physically possible to do it the other way around.

If you can't find a socket for that 12v plug cut it off and connect the wires to the pump.

I have to ask Kando, how old are you? If you're just a kid ok, but if you are an adult I can't take any more smiley

______
Rob
30  Development / Other Hardware Development / Re: List of tools for surface mount work on: April 11, 2014, 10:10:33 pm
Those head-mounted magnifiers work well, and you can flip down more power when you need it as most of them have an extra lens or two on swivels/hinges.

______
Rob
Pages: 1 [2] 3 4 ... 579