Show Posts
Pages: 1 ... 126 127 [128] 129 130 ... 361
1906  Using Arduino / Programming Questions / Re: Self-modifying code on Arduino? on: August 02, 2013, 12:21:33 am
If there's enough room in a core, a Propeller might be a good choice as well. The code you load is from off-chip and can be determined at run time.
1907  Using Arduino / General Electronics / Re: converting 5v to 12 V on: August 02, 2013, 12:07:57 am
Is that what the ULN2xxx Darlington Arrays have?


The unl2 are paired up of 2 regular npn transistors for a high gain output ...

That's not the whole circuit according to the maker and EE's I have known.
1908  Using Arduino / Programming Questions / Re: Self-modifying code on Arduino? on: August 01, 2013, 09:41:48 pm
You should make a study of Finite State Machines and C pointers, especially function pointers as well. Combine the two or just stick to state machines and your execution path can be totally responsive to events and process state. There's about nothing that SMC can do that beats that.

Quote
I could store some of the constant values for given iteration of the loop into immediates that I otherwise have to fetch from memory.

OTOH I could be the one that doesn't know what you mean by SMC instead of you.

Perhaps if you start with telling what you are trying to do and how you expect to get there using SMC?
1909  Using Arduino / Programming Questions / Re: Two Potentiometer Arduino to xbee to xbee to Arduino to two Led's on: August 01, 2013, 09:32:21 pm
Hi Ben, is Ben just once okay?

I see what you are trying to do and you're not far off the mark. One thing that would help is if you print the incoming bytes as HEX (separated by printed spaces) and put in a newline before printing a SYNCH byte. that way your printed data won't run together.

It would probably not be a bad idea to turn the data into ASCII text or BCD digits that allow more checking than raw binary.

As far as reading incoming data, always check that bytes are available before reading them.

if (Serial.available()) will be true if there is only 1 byte so that test is not good to read 2 bytes.

You're better off checking for and reading 1 byte per pass through loop() anyway, most times there will be no bytes to read, the Arduino could be doing something else like watching for user input or blinking the pin 13 led to show working status.

You should be reading (in HEX) FE data FF data FE data FF data ..... where data is a hex value from 00 to FD. You will need to print leading zeros for data bytes less than 0x10. Do that just to see what you're getting from the transmit.

Set up a state variable with some rules like:

state 0 expects FE. if FE then change state to 1 else change state to 100 (=error)

state 1 expects a data byte in range 0 to FD. if good then process data and change state to 2 else state = error

state 2 expects FF..............

state 100, error, read until you get an FE then set state = 1.

Every time you get a byte and process according to state, return to run loop again. You only process state after reading a byte.

And that is where I set up a BlinkWithoutDelay to serve as a working status indicator.

1910  Using Arduino / Programming Questions / Re: Two Potentiometer Arduino to xbee to xbee to Arduino to two Led's on: August 01, 2013, 09:02:59 pm
Serial data is NOT guaranteed to be delivered. What are you going to do when one of the bytes gets lost?

You seem to have a misunderstanding of what data each sensor sends. Each sends ONE byte (not two or three) per iteration of loop.

Code:
if (Serial.available()) {   // are there any bytes available on the serial port ???
Serial.available() returns the number of bytes available, not TRUE or FALSE. Do NOT use it like it returned TRUE or FALSE.

What IS your problem?

Gee Paul, calm down. 0 bytes = 0 which also = FALSE while 1 or more is non-zero = TRUE.

That's the test that I use and it has never failed me.
1911  Using Arduino / Programming Questions / Re: Self-modifying code on Arduino? on: August 01, 2013, 08:58:30 pm
What do you expect to get out of SMC that you can't get from data-driven code, perhaps a set of state machines?
1912  Using Arduino / Programming Questions / Re: Help Please! Can someone check the source code of my program please? on: August 01, 2013, 08:55:43 pm
Perhaps being in some part of a closed refrigeration system would do that?
1913  Using Arduino / General Electronics / Re: converting 5v to 12 V on: August 01, 2013, 08:17:43 pm
Is that what the ULN2xxx Darlington Arrays have?
1914  Using Arduino / Programming Questions / Re: Help Please! Can someone check the source code of my program please? on: August 01, 2013, 08:15:08 pm
That table seems pretty deterministic.
1915  Using Arduino / General Electronics / Re: Wiring Arduino Micro with Xbee Radio on: August 01, 2013, 12:03:37 pm
TTL serial is one of those things where the state of the wires is inverted to what I expected. OFF is HIGH.

1916  Using Arduino / General Electronics / Re: converting 5v to 12 V on: August 01, 2013, 11:57:51 am
I paid $3.50 for a 12V 1A wall wart...
1917  Community / Bar Sport / Re: Critical thinking and programming. on: August 01, 2013, 11:10:47 am
Quote
I never had any experience in school that was like someone trying me to teach how to learn

When I was at school I was taught the "scientific method" which I believe does teach you to think critcally and solve problems in a general, reasoned, methodical way. I agree there is a sad lack of people being trained to do this.

For the past handful of years there's been a back-to-the-cave movement that's actively trying to kill any such training in public schools. They've made some anti-progress and are pushing hard in backwater states. Science is seen as anti-religion. It's scary out there!

Quote
There is a place for the "hunch" which I think is the subconscious mind doing a lot of work in the background. Of course the value of the hunch depends on the skills, knowledge and experience of the person having it.

Relying on hunches is real bad when dealing with technical or logical problems though.

Quote
Talking of the subconscious;

Do you never find its best to put a problem down, not think about it at all for a while, and then when you come back 'ping' the light comes on and the problem is solved.

Likewise you spend hours and hours banging your head against a wall searching for a fault and you are completely blind to it. You stop and start to talk the problem through with somebody. They don't say a word and yet all of a sudden the answer becomes so blindingly obvious and you cannot understand how you missed it.

Always. I also used to keep a pen and pad next to my bed for the times answers came to me in dreams.

It's about left brain focus. We learn mostly that in school especially in rote learning. But when the focus gets too tight we lock ourselves in and the needed detail or understanding out. It becomes like a 1-mind groupthink where anything outside is unthinkable.
Taking a break and relaxing unlocks that and lets the right brain input what it's been working on which sometimes is the answer or the direction the answer is in.

A lot of what schools do is to silence the right brain, turn creativity down, while building the left brain to dominance. "Are you paying attention!?" --- demands left brain focus.

We need both sides and we need control not to distract ourselves when we do need focus and not to fixate when we don't. Left brain is word strong, right brain is image strong. We need both.
 
1918  Using Arduino / General Electronics / Re: Wiring Arduino Micro with Xbee Radio on: August 01, 2013, 10:41:37 am
That took me a while but I figured it out.

3.3V through the resistor provides a pullup.
When TX is low it pulls that down.
Mostly TX is high so there's not much wasted where a voltage divider would waste more.
1919  Using Arduino / General Electronics / Re: Wiring Arduino Micro with Xbee Radio on: August 01, 2013, 09:53:29 am
What jack said! +1

Greetings!

I am having some trouble using the Arduino Micro board with an Xbee S1 and S2 radio, neither have worked. I am trying to directly connect the Xbee to the Micro without a shield. After wiring the boards up I tried receiving serial data on another radio with a FTDI USB shield with the same PAN ID / channel using a terminal program. Is it not possible to directly wire to an xbee radio? If not any suggestions would be extremely helpful.

Here is my wiring diagram:
    Xbee                           Arduino
VCC or 3.3 V   -----------     3V3
TX or DOUT    ------------    RX or 0
RX or DIN       ------------    TX or 1
     GND         ------------    GND



You can shift 5V to 3.3V using 2 resistors to make a voltage divider. 1 resistor should be half the ohms of the other (I used 2 4.7k resistors in series to make a 9.4k, got plenty 4.7k and no 9.4k). 5V goes into the smaller resistor and connects to both the larger resistor (which goes to ground and drains 1/3rd of the 5V) and the 3.3V (the other 2/3) out wire.

You can run 5V through 2 diodes to get 3.6V. Each diode drops .7V.

If the Arduino is connected to a PC through the USB cable then don't connect the XBEE to pins 0 and 1 since the USB connect uses them. Instead use the SoftwareSerial library and 2 other pins like 8 and 9. I can get 57600 maximum speed using SoftwareSerial but that should be fast enough.
1920  Using Arduino / General Electronics / Re: converting 5v to 12 V on: August 01, 2013, 09:39:44 am
If you're going to covert without external power then be really careful about how much current you draw. Arduino IO pins are not good for much 5V, not recommended for more than 20 mA of 5V, or total from the board of 200 mA so how much 12V would you expect to get out?

It's better and cheaper to use external power and be sure to connect the grounds unless you use an isolator to level up with.
Pages: 1 ... 126 127 [128] 129 130 ... 361