Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Fifty-Nine
Oct 15, 2003

UserNotFound posted:

Actually, what you should look into is to is use a 555 timer to blink the lights very quickly. 99% of LED lights do this to save power.

You could also use pulse width modulation to vary the intensity if you wanted. I don't know how useful it would be for a bike headlight, but hey, it's there if you want it! v:shobon:v

Adbot
ADBOT LOVES YOU

Fifty-Nine
Oct 15, 2003

TwystNeko posted:

Okay, I've just gone through this thread, and I've got a couple of possibly stupid questions.

I'm getting into doing PIC programming, the PIC 16F628A in particular, and I'm making one of those silly POV toys - the kind that you swing around, and it displays a message. I've got the programming basically done - I'm running 8 RGB LEDs, and the way I'm storing the data takes 3 bytes per 8-pixel column. No problem there.

So, the first question: I see reference to "ICSP" for programming PICs, does anyone have experience with this? I see references to "schottky" diodes, and I have no idea what those are. I've got some "rectifier" diodes, but haven't a clue if they're the same thing (I assume not)

Second - I want to run this thing off a 9V battery, but of course the circuit only wants 5V. I assume there's a simple way to drop to about 5V with a voltage regulator, right?

One of the future projects that I want to build is a wall-mounted, rotary POV device that is computer controlled via serial (or USB - the PIC 18F4550 series looks great!) - I just have to figure out a good way of transferring data and power to a spinning platform.

In-circuit serial programming allows you to program your target circuit without taking the microcontroller itself out of the circuit. You'll need an ICSP compatible programmer (such as a PICKit2), a PIC (duh), and some resistors. Take a look at this picture:



This picture in particular refers to the PICKit2 programmer, but the basics apply to all the Microchip ICSP programmers. You connect the two ICSP pins directlyto the proper device pins, and you connect the VPP pin from the programmer to the ~MCLR pin. You also connect the programmer to your circuit's Vdd/vss.

The extra circuitry is necessary for two reasons: to hold ~MCLR high during normal use (it's an active low reset) and to isolate the programmer from your Vdd/vss. During programming, the programmer drives ~MCLR to +12V so the diode prevents the programmer from adversely affecting your power supply.

As you can see from the picture, you can also use a 470 ohm resistor instead of a schottky diode. For all my PIC projects I've used a resistor in this capacity and it's worked fine. You could try it with the normal diode--schottky diodes are essentially normal diodes with faster switching times as far as I know--but it might not work. Also, I suppose things might explode or something.

As for your second question, I don't have much experience with using batteries to power microcontrollers so I'll let someone else answer that one. My guess is that you'd be fine depending on how much current you're drawing to power those LEDs.

Fifty-Nine
Oct 15, 2003

Delivery McGee posted:

Also, how do you tell which end of the resistor to start from when reading the code? None of the ones I've ripped out of various broken devices seem to have any way of telling -- all the stripes are the same distance apart and from the ends.

Resistor codes always end with a tolerance band which specifies the precision of the resistor's indicated value. It could be gold (+-5%), silver (+-10%), red (+-2%), or brown (+-1%). In practice I've only ever seen resistors with gold or silver tolerances, in which case you always read it starting on the side that opposite the gold/silver tolerance band.

Now, if your tolerance was red or brown you'd still start on the opposite side of that, but if your resistor value began with the same color as well, then I have no clue how you'd tell just by looking at the bands.

Fifty-Nine
Oct 15, 2003

Blackhawk posted:

I need some help with interfacing 5V sensors to 3.3V circuits. I'm trying to interface a 5V analogue output (0-5V) pressure transducer to a 3.3V datalogger and I want to do it with as little error as possible. The simplest way would probably be using 2 resistors as a voltage divider to drop the 0-5V signal to 0-3.3V however I'm worried about the error inherent with this method and there's probably much better ways to do it.

So the pressure transducer has a single analog output? If that's the case, you're going to need a analog-to-digital converter (ADC or A/D) of some sort. The ADC will have a reference voltage you can set, so the 5V-3.3V interface shouldn't be a problem.

There's lots of ways to build ADCs, but if you're that concerned about accuracy/precision, you should probably just get a single-chip type thing (try https://www.analog.com).

Your maximum precision will be limited by how wide the input bus on your data logger is--you can't do any better than +-1/2 * LSB (least-significant bit). Basically, the ADC maps an analog value to a finite number of digital values, which results in the values being quantized. You can calculate the precision by determining how big of a change is necessary in the analog value to affect the digital value.

To calculate that is actually pretty simple--we take the range of analog values, (5V - 0V) = 5V, and divide it by the total range of digital values, 2^width. The quantization error is then +-1/2 of the resulting value for reasons I'm forgetting.

+-1/2 * (VrefH - VrefL) / (2 ^ width)

For instance, supposed you use an 8-bit bus, then your maximum theoretical precision would be:

+-1/2 * 5V / (256) = +- 9.766 mV

Pretty reasonable. Note that the more bits you use, the better your precision.

You will also need to consider your sampling rate when deciding on an ADC--how fast do you want to record values from the transducer?

Also, what are you using as your data logger? Is it something that was pre-built or could you describe the internals?

edit: beaten, but my post has MATH

Fifty-Nine fucked around with this message at 16:54 on Apr 19, 2008

Fifty-Nine
Oct 15, 2003

Cross_ posted:

Since you mentioned FPGAs, I almost picked up one of these boards last year:
http://www.digilentinc.com/Products/Detail.cfm?NavTop=2&NavSub=423&Prod=S3EBOARD

I've got one of these, as well as an Altera DE2-70. For a beginner, I can't recommend the Spartan kit enough. The user manual is very well-written--it's practically a tutorial for how to use the peripherals on the board. You'll have to get a working knowledge of Verilog/VHDL first, but once you do you can do alot with this board.

To add fuel to the Verilog/VHDL fire, I've been programming heavily in VHDL for the past two years or so, and I absolutely hate it. I can get things done and it works fine, but it's just so goddamn verbose.

On the other hand, I like Verilog, but there's one thing I still haven't figured out. From what I understand, it's based on C, no? Why on earth did they choose to use begin/end instead of curly braces? Could they think of no other way to implement the concatenate and repeat operators or something?

Adbot
ADBOT LOVES YOU

Fifty-Nine
Oct 15, 2003
I would have assumed the synthesizer would figure this out automatically, but perhaps you could run the output of the ibufds through a global clock buffer (bufg)?

I'm looking at some code I worked with recently that used an LVDS clock for RocketIO, and it looks like it does ibufds->bufg->pll_adv to generate the clock. Here's the code, for reference: http://code.google.com/p/infinibandfpga/source/browse/trunk/Physical/RocketIO_Wrapper.vhd. REFCLK_P and REFCLK_N are the differential clocks.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply