This source describes Open Hardware and is licensed under the CERN-OHL-S v2.
You may redistribute and modify this source and make products using it under the terms of the CERN-OHL-S v2 (https:/cern.ch/cern-ohl).
This source is distributed WITHOUT ANY EXPRESS OR IMPLIED WARRANTY, INCLUDING OF MERCHANTABILITY, SATISFACTORY QUALITY AND FITNESS FOR A PARTICULAR PURPOSE.
Please see the CERN-OHL-S v2 for applicable conditions.
- Now using the classic step and dir interface fot the stepper driver, deprecated SPI motion control of TMC5160 (spi mc eliminates every timing problem), for compatibility with pololu style stepper driver
- Now using simple PID for the control, possibily only proportional with kp step on error range, deprecated the volumetric and cinematic model for the AMBU
- PID For volume target, PID For pressure target, PID for volume rateo, PID for pressure rateo, not only one selected by the operational mode for clearness
- Encoder reading with quadrature decoder, functioning only with first two channel, now using the classic encoder library.
This is the starting concept of the project, the first stable firmware will be published after finishing the testing part.
*/
#include <PID_v1.h>
#include <TMCStepper.h>
#include <Encoder.h>
#define EN_PIN 7 // Enable
#define DIR_PIN 8 // Direction
#define STEP_PIN 9 // Step
#define CS_PIN 10 // Chip select
#define EN_PIN_B 24 // Enable
#define DIR_PIN_B 26 // Direction
#define STEP_PIN_B 25 // Step
#define CS_PIN_B 15 // Chip select
// #define SW_MOSI 66 // Software Master Out Slave In (MOSI)
// #define SW_MISO 44 // Software Master In Slave Out (MISO)
// QuadEncoder encA(1, 0, 1, 0); // Encoder on channel 1 of 4 available
// // // Phase A (pin0), PhaseB(pin1), Pullups Req(0)
// QuadEncoder encB(2, 2, 3, 0); // Encoder on channel 1 of 4 available
// // // Phase A (pin0), PhaseB(pin1), Pullups Req(0)
// // QuadEncoder knobF(3, 4, 5, 1); // Encoder on channel 1 of 4 available
// // // // Phase A (pin0), PhaseB(pin1), Pullups Req(0)
EncoderknobP(22,23);
EncoderknobV(4,17);
EncoderknobF(5,6);
EncoderencA(0,1);
EncoderencB(3,2);
//Specify the links and initial tuning parameters
PIDPressure_PID(&InputP,&OutputP,&Pressure_SP,1,0.01,0,DIRECT);//P_ON_M specifies that Proportional on Measurement be used //P_ON_E (Proportional on Error) is the default behavior