Show Posts
Pages: 1 ... 63 64 [65] 66 67 ... 151
961  Using Arduino / Programming Questions / Re: untyped pointers. on: November 30, 2012, 05:29:45 pm
void pointers are actually fairly simple to undestand, as long as you remember two things:

1) Before you use them, you will need to recast them back to the appropriate type.
2) Once they are recast back to the right types, you will need to let your code know that they are pointers.

Take this for example:

Code:
value = * (int *) myptr;

"(int *) myptr" recasts myptr to a pointer to an int. The "*" in front of "(int *) myptr" tells your code that the recast type is a pointer.

You can think of it as two statements:
Code:
  int * tmp;

  tmp  = (int *) myptr; //tmp now points to the same content as myptr does;
  value = *tmp; //value takes on the content pointed to by tmp
962  Using Arduino / Displays / Re: [CODE]Control a 7 segment display with a shift register on: November 30, 2012, 05:24:41 pm
I would rewrite your code slightly:

Code:
void sendBinary(byte number)
{
        unsigned char mask = 0x80; //msb first
do {
PORTB_LOW(CLK_PIN); //clear clk
                if (number & mask) PORTB_HIGH(DATA_PIN); //send '1'
                else PORTB_LOW(DATA_PIN); //send '0'
                PORTB_HIGH(CLK_PIN); //strobe out the data
                mask = mask >> 1; //for the next bit
} while (mask);
}

On most machines, this approach provides near 50% duty cycle for the clock pin and is also faster than your routine.
963  Using Arduino / Programming Questions / Re: moving up from the IDE to atmel studio or ?? on: November 30, 2012, 05:18:12 pm
Quote
Atmel Studio 6 is just an improvement in the IDE

Not quite.

AS4 is very simple and has a small foot print, but otherwise a piece of @#$% in terms of its user interface - I wouldn't touch it myself.

AVR Studio 5 / Atmel Studio 6 are based on Microsoft products and totally different interface - those who program in VC should recognize that quickly. The user interface is state of the art, but they are bloated - AS6 is far more bloated than AS5 without offering much to AVR programmers to justify that increase, in my view.

Eclipse is just an ide and can be made to work with other compilers.

964  Using Arduino / General Electronics / Re: 4-20ma output from Arduino on: November 30, 2012, 05:12:42 pm
For a voltage input, you will need to convert that into a current output, mirrored to the other leg of a current mirror (typically a widlar current mirror).

Let's say that the voltage signal is referenced to ground. You use 3 npn to form a widlar current mirror. On the output leg, it funds as a current sink, and its current sink is regardless of the load / voltage on that leg (within certain limitations).

But most people would not just use that. The output is typically buffered by a current amplifier - in this case a pnp. The resistor on the pnp's emitter determines the delta V / delta I relationship for the current output.

965  Using Arduino / Programming Questions / Re: untyped pointers. on: November 30, 2012, 05:02:41 pm
A couple issues:

1) data_handler needs to be declared "void *" so that it can return a pointer to void.
2) When you use that void pointer, you will need to know its type and recast it back.

Here would be an example:

Code:

void * data_handler(...) {
...}

void * myptr;
  myptr=data_hander(1); //myptr points to cfg.a (int)
  value = * (int *) myptr;

  myptr=data_handler(2); //myptr points to cfg.st (unsigned char *)
  printf("cfg.st=%s", (unsigned char *) myptr);

  myptr=data_handler(3); //myptr points to cfg.d (uint8_t)
  printf("cfg.d=%4d\n", * (uint8_t *) myptr);


Just some example.
966  Using Arduino / General Electronics / Re: Nice way to power an LCD backlight on: November 30, 2012, 02:48:11 pm
Quote
The regulator is setup as a constant current source. With 22 ohms across 5 volts, you have a constant 230 milliamps regardless of V-in.

The regulator is NOT setup as a constant current source: it is setup as a constant VOLTAGE source. The only reason it is providing (fairly) constant current to the LED is due to its constant VOLTAGE output on a constant load (that resistor).

The advantage I see is that by wiring the led pre-regulator, you have lessened the voltage drop thus power dissipation over the regulator.

The drawback obviously is that the voltage drop over the led + regulator is now much higher.
967  Using Arduino / General Electronics / Re: how critical is mosfet gate pulldowns? on: November 30, 2012, 01:45:25 pm
Quote
which im wondering is it worth the effort?

It depends on  your driving circuitry and generally is not critical: most of the times you are driving a n-channel mosfet with a totem output stage or a open drain/collector output stage. Both types of circuits short the gate to ground when they go low, negating any benefits from a pull-down mosfet.

Pull-up mosfets is another question, for open drain / collector drivers.
968  Using Arduino / General Electronics / Re: MOSFET Driver Types on: November 30, 2012, 01:42:51 pm
Most mosfet drivers are designed for N-channels.

If you are driving a h-bridge, you need a h-bridge driver (both high side and low side).
969  Using Arduino / Programming Questions / Re: moving up from the IDE to atmel studio or ?? on: November 30, 2012, 01:23:26 pm
Both AS and Eclipse offer real project management that is easy and flexible.

I personally use IAR / CodeBlocks: IAR due to its comformity and CB due to its size / flexibility. IAR offers hardware debugging support and CB doesn't.

AS (both 4.x or 5.x) are also very good but with limited support for older programmers. AS6 is useful only if you use 32-bit avr offering.
970  Using Arduino / Sensors / Re: Help with signal conditioning on: November 30, 2012, 07:16:13 am
Quote
I wonder if somebody can point me to a software algorithm or an hardware solution to obtain nice square waves (sharp attack, sustain and, what's missing here, a sharp release).

Fundamentally, there is no good solution.

Alternatively, you can introduce some derivative gain, similar to a PID controller, for this.

971  Using Arduino / General Electronics / Re: Using mosfets to switch low current from a high current gate voltate on: November 30, 2012, 07:08:23 am
Quote
Using mosfets to switch low current from a high current gate voltate

You have understood a subject matter if you can articulate it in a jargon-free way.

That would have been a sign of sophistication.
972  Using Arduino / General Electronics / Re: Nice way to power an LCD backlight on: November 30, 2012, 06:14:33 am
How's that different from powering the led as a load to the regulator?
973  Using Arduino / Programming Questions / Re: How to avoid floating point math on: November 30, 2012, 06:04:26 am
Your intuition is correct. Floating point math is typically implemented via calls. When floating math is used in the isr and elsewhere in the main loop, you can get into re-entrancy -> big issues.

Sometimes 32-bit multificaton is done via calls so same issue.

You can simplify the math or to use a flag.
974  Community / Bar Sport / Re: -- new arduino on kickstarter? it is a fake? on: November 29, 2012, 07:32:21 pm
Quote
There's no mention of "misleading" AFAIK,

Precisely. What's misleading is highly subjective: what's misleading to you may not be misleading to me, and vice versa.

975  Community / Bar Sport / Re: -- new arduino on kickstarter? it is a fake? on: November 29, 2012, 06:40:17 pm
Quote
This statement (if made by the two people who supposedly worked for the contractor) may be technically correct but it is misleading,

Is this one of those "true but false" thing?

In a court of law, are you required to tell the truth or are you required to not mislead?

Misleading or not is a perception (by others). As long as they provided the facts, they are done. How the facts are to be perceived by others is out of their control and it wouldn't be fair to hold them accountable for things they have no control over.
Pages: 1 ... 63 64 [65] 66 67 ... 151