Hello everyone, I need a little help in this program i'm working on. I'm trying to create a gated square wave for ultrassonic equipments. I've used the arduino DUE and the code below to generate 2 square waves on pins 7 and 8 respectively.
I was using the 74LS132 logic gate to make the gating but this chip is messing my signal so bad that I cant drive the ultrassonic device.
Is there a way to make the gating in the DUE code and output the already gated signal without all this distortion?
Im generating 2 precise signals from due clock, see the program below, and it works great, I just need the gating, any help would be appreciated:
#include <Arduino.h>
const unsigned long serialPeriodMillis = 2000;
unsigned long previousMillis = 0;
void setup()
{
int32_t mask_PWM_pin = digitalPinToBitMask(7);
REG_PMC_PCER1 = 1 << 4;
REG_PIOC_PDR |= mask_PWM_pin;
REG_PIOC_ABSR |= mask_PWM_pin;
REG_PWM_CLK = 0;
REG_PWM_CMR6 = 0 << 9;
REG_PWM_CPRD6 = 1300;
REG_PWM_CDTY6 = 650;
REG_PWM_ENA = 1 << 6;
int32_t mask_PWM_pin1 = digitalPinToBitMask(8);
REG_PMC_PCER0 = 1 << 4;
REG_PIOC_PDR |= mask_PWM_pin1;
REG_PIOC_ABSR |= mask_PWM_pin1;
REG_PWM_CLK = 16;
REG_PWM_CMR5 = 0 << 9;
REG_PWM_CPRD5 = 30000;
REG_PWM_CDTY5 = 9000;
REG_PWM_ENA = 1 << 5;
Serial.begin(115200);
Serial.println("Serial on");
}
void loop()
{
if (millis() - previousMillis > serialPeriodMillis) {
Serial.println("TIC");
previousMillis = millis();
}
}
Thanks