luni64 / encsim Goto Github PK
View Code? Open in Web Editor NEWQuadrature signal generator for testing encoder software. Requires a PJRC Teensy board. Generates quadrature signals with adjustable frequency, phase and bouncing
License: MIT License
Quadrature signal generator for testing encoder software. Requires a PJRC Teensy board. Generates quadrature signals with adjustable frequency, phase and bouncing
License: MIT License
Hello,
Great work. However, it seems that EncSim disables the PWM generation, am I correct ?
Here is my code:
`// Utilise https://github.com/luni64/EncSim
// et https://github.com/luni64/TeensyDelay
#include <TeensyDelay.h>
#include <EncSim.h>
EncSim<3, 4> simulator; // use pin 3 and pin 4 as output
int32_t i = 0;
const uint8_t pwm_inca = 5;
const uint8_t pwm_incb = 6;
const uint8_t pwm_incc = 9;
const uint8_t pwm_incd = 10;
void setup() {
// Résolution du pwm
analogWriteRes(12);
// Fréquence du pwm (6.25 kHz max)
analogWriteFrequency(pwm_inca, 6000);
analogWriteFrequency(pwm_incb, 6000);
analogWriteFrequency(pwm_incc, 6000);
analogWriteFrequency(pwm_incd, 6000);
// Génération de PWM à rapport cyclique fixe pour tester les sorties analogiques via le LTC2645
analogWrite(pwm_inca, 2048);
analogWrite(pwm_incb, 2048);
analogWrite(pwm_incc, 4095);
analogWrite(pwm_incd, 4095);
simulator.begin();
simulator
.setFrequency(150) // 150Hz count rate
.setPhase(90) // normal 90� phase shift
.setTotalBounceDuration(0); // no bouncing
simulator.moveRelAsync(1000000);
}
void loop() {
// if (150 + i10 < 1000000) {
// i+= 10;
// }
// simulator
// .setFrequency(150 + i10) // (150 + i*10)Hz count rate
// .setPhase(90) // normal 90� phase shift
// .setTotalBounceDuration(0); // no bouncing
//
// simulator.moveRelAsync(1000000);
// delay(10);
}`
Thanks in advance for your answer,
Nicolas
Hi thanks for this project it help me a lot on a unit test on Industrial Ultrasonic Equipment validation.
Is it possible to define 2 EncSim like this :
EncSim simulator(0,1);
EncSim simulator2(3,4);
and apply different configuration (freq, period) on each ?
I hope my request is clear for you
Thanks a lot
M.GIRARD
Hello!
First of all, thanks a lot for the A quad B programs!! I needed a A quad B emulator which could generate pulse upto 1 MHz, and this solution would work well for me.
However, I am facing a glitch when I try to compile the "SerialControl" code using Arduino IDE 2.0.4 for a Teensy 4.1 board.
Please note that, I have not made any changes to your "SerialControl" code base.
The error message is attached. Could you please help me with a suggestion on what I should do to get rid of this?
Regards,
Sanjib
SerialControlTeensy4_1_error.txt
Hi Luni, IntervalTimerEx in the EncSim library needs changes for compatibility with your latest update to IntervalTimer in Teensy cores. I don't know if you want to keep support for USE_CPP11_CALLBACKS, but I assumed you did, and I modified my own copy of EncSim to support TEENSYDUINO >= 159, your existing USE_CPP11_CALLBACKS, and and the original callback_t = void ()(void);
The changes are pretty simple. In IntervalTimerEx.h, I added a definition of your latest callback_t for TEENSYDUINO >= 159, and then elsewhere in the H and CPP files, conditionals based on USE_CPP11_CALLBACKS were changed to ((TEENSYDUINO >= 159) || defined(USE_CPP11_CALLBACKS)). There was one place where you used an explicit callback type, and I changed that to callback_t.
Here is the modified conditional logic from the top of the H file, with the #include and callback_t copied from cores\Teensy4\IntervalTimer.h in TD 1.59b6.:
#if (TEENSYDUINO >= 159)
#include "inplace_function.h"
using callback_t = teensy::inplace_function<void(void), 16>;
using relay_t = void (*)();
#elif defined(USE_CPP11_CALLBACKS)
#include
using callback_t = std::function<void()>;
using relay_t = void (*)();
#else
using callback_t = void ()(void);
using relay_t = void (*)();
#endif
Hello!
I noticed that you have the beginning of code for this project for the Teensy 4 and 4.1 boards in the config files. I've tried to run this on my 4.1 board with no luck. If you have any suggestions on how to incorporate the 4.1 into this project, please let me know!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.