HI all.
I want to make a programmable pulse generator using Arduino.
The "specifications" I need are the following:
A) first output generates 10 usec pulse with frequency 10 Hz.
B) One "enable" input. When it goes high all others pulses get generated.
All following pulses are generated once with relative delay to the first pulse A after B went high.
C) 10 usec pulse with variable 10-200 usec delay
D) 5-20 msec pulse with delay from 1 msec to 20 sec.
All pulses are TTL.
I would like to set up (throuhg comport or LPT port or USB) delay of pulse C, delay and width of pulse D.
Is it possible to do with one arduino uno board without a shield.
Thank in advance for any advise where to start.
Here is a script I use to do pulse width modulation for a electroplating tank
the pulse width is determined by a potentiometer to the analog in.
You could just as well control it with input from the USB port. There are lots of sample of how to do this in the Forum
// set pin numbers:
int platepin = 2;
int plateGrnd =3;
int unplatepin =4;
int unplateGrnd=5;
int DutyHi;
int DutyLo;
float DutyRatio;
void setup() {
// set the digital pin as output:
pinMode(13, OUTPUT);
pinMode(2, OUTPUT);
pinMode(3,OUTPUT); // go low when 6 is high
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);// go low when 7 is high
}
void Sequence_plating()
{
digitalWrite(unplatepin,LOW);
digitalWrite(unplateGrnd,HIGH);
digitalWrite(platepin,HIGH);
digitalWrite(plateGrnd,LOW);
delay(10 *DutyHi/1023);
digitalWrite(platepin, LOW);
digitalWrite(plateGrnd,HIGH);
digitalWrite(unplatepin, HIGH);
digitalWrite(unplateGrnd,LOW);
delay(10*(1023-DutyHi)/1023);
}
void Get_Ratio()
{
DutyHi = analogRead(0);
DutyLo = 1023; //analogRead(1);
DutyRatio = (DutyHi+1/(DutyLo+1)); // 1023/0 max
if ( DutyHi <= 700) // warn that duty cycle is approching unplating
{
digitalWrite(13,HIGH);
}
else
{
digitalWrite(13,LOW);
}
}
void loop()
{
Get_Ratio();
Sequence_plating();
}
I would write a separate sketch for that and do the pulse 1us in assembly.
Google direct port manipulation to set the line HIGH and LOW
and use NOP (assembler instruction) to get length exact 1 usec