Paging @joeyd999 ....there's probably a PIC wizard out there that could solve this in a weekend
I don't know from where you are getting your information.Let me back up a step. I'm very passionate about perfecting this, don't ask why. Maybe there's something you guys are equally passionate in, I don't know. Regardless, I am interested in seeing if I can get EVEN BETTER than 0.5us, maybe better than 0.1us.
The problem that arises is the arduino clock frequency doesn't translate into perfect timing. For instance if I use the micros() code for timing, I can tell it to flip a pin HIGH and that number is effectively divided by 4 - meaning rounded up or down. One gentleman tested this for very crucial timing with PPM signals used with R/C radios, and the 1500us pulse was randomly either 1496, 1500, 1504 - and occasionally 1492 and 1508. That's 16us, not 0.5us. That variance ALONE is over 0.8% at 2ms, meaning all my mechanical bits must have less than a 0.2% margin of error to result in my end figure of +/-0.5%. NOTE: I've bolded and underlined some very important concerns.
AnalogKid, while I appreciate your contribution, I again refer to the last sentence in post #1. All my training is that which I've given myself and I'd be able to rebuild a corvette motor faster than design a circuit with your BOM. Also, didn't I make it clear I already have the waveform generator?
I really don't like to turn away people eager to help me, but I am only seeking 1 of 2 things: arduino coding guaranteed to be accurate to 0.5us or pointers on implementing a known-accurate waveform gen with arduino/mosfet control.
You're getting pretty digital for an "AnalogKid" Kid. Welcome to the club.I agree. Today's PICs might be the greatest thing since sliced bread, but I don't think you'll get sub-microsecond precision in a uC unless it has a RISC core running hand-tuned assembler code. OTOH, there's probably a PIC wizard out there that could solve this in a weekend. Personally I'd put everything in a Lattice CPLD, but we all have our favorite toys.
ak
Tinker toys are fun to play with.You're getting pretty digital for an "AnalogKid" Kid.
I completely understand that the ATmega328 clock has high resolution. The PROBLEM is code doesn't flip pin states with just 1 clock cycle on the Arduino, and this is why I don't want to have the Arduino controlling the solenoids. Even the most efficient code on the arduino can't flip an output pin close to 0.06us. Here is a picture of what happens when basic code sets an output high then low continuously, all without any delays added. It takes 4.15us to set the output pin LOW (which effectively gets added to the duty cycle). Isn't 4.15us much larger than 0.06us, or am I crazy?ATmega328 can operate with a clock frequency of 20MHz. That gives you 0.05μs resolution ±0.001%.
Even if you use an Arduino running at 16MHz, that will still give you 0.06μs resolution ±0.001%.
then we're back to an external clock and divider to get the FET drive waveforms. If part of the external divider is a programmable downcounter, then you can change the output pulse width through the arduino without affecting the system resolution. Is this more like what you're after?I don't want to have the Arduino controlling the solenoids.
I can assure you I'll happily listen to advice when I get help figuring out the holes in my original idea first. I'm not sure about you guys, but when someone asks me a questions such as "Why has my car's gas mileage dropped?", I tend to explain why rather than tell them to get a Prius.Odds are he won't take our advice regardless of what it is.