Buenas comunidad, necesito enviar a un circuito una señal PWM de 14 micro segundos, es decir, debe estar en ON por 14 microsegundos y en OFF por 14 micro segundos, como haria para hacer el codigo y sacar esta señal por un puerto de salida digital de un arduino uno.
Hola
Cual es el proposito de este proyecto?
RV mineirin
Hello @ruilviana I will do a simple tdr prototype for testing coaxial cable. so I need to send this PWM signal, and them use the internal arduino comparator to check the voltage level of the circuit. but first I need to send the PWM signal.
Hi @,
An output with 14 microseconds ON and 14 microseconds OFF,
it does not necessarily need a PWM.
A PWM is in theory a signal where the duty cycle can be adjusted.
As it was not mentioned which controller should be used or the voltage level for this signal, I would recommend using ESP32. Using the LEDc feature to generate this signal.
The ESP32 using this feature can generate pulses from 1 Hz (1 second) to 40 MHZ. (0.025 microseconds),
Lo podés hacer usando interrupciones del timer1
Te dejo un código de ejemplo de como setear el timer.
// AVR Timer CTC Interrupts Calculator
// v. 8
// http://www.arduinoslovakia.eu/application/timer-calculator
// Microcontroller: ATmega328P
// Created: 2021-07-12T15:26:41.396Z
#define ledPin 13
void setupTimer1() {
noInterrupts();
// Clear registers
TCCR1A = 0;
TCCR1B = 0;
TCNT1 = 0;
// 71428.57142857143 Hz (16000000/((223+1)*1))
OCR1A = 223;
// CTC
TCCR1B |= (1 << WGM12);
// Prescaler 1
TCCR1B |= (1 << CS10);
// Output Compare Match A Interrupt Enable
TIMSK1 |= (1 << OCIE1A);
interrupts();
}
void setup() {
pinMode(ledPin, OUTPUT);
setupTimer1();
}
void loop() {
}
ISR(TIMER1_COMPA_vect) {
digitalWrite(ledPin, digitalRead(ledPin) ^ 1);
}
Usalo como base para tu código, luego agrega lo que haga falta.
La salida de los pulsos está definida en el pin 13 pero cambialo al que te convenga.
Que no te asuste ver que el timer está seteado al doble de frecuencia, es así porque cada 14 useg genera el cambio de estado que necesitas, entonces las interrupciones se generan al doble de la frecuencia final.
Saludos
PD: @iotaa Por favor respeta las Normas y a quienes no manejan inglés. Si posteas en el subforo en español, escribe en español (o mejor dicho, en castellano). Saludos
Muchas gracias
This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.