Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion 3-Software/Arduino/.clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ PenaltyReturnTypeOnItsOwnLine: 200
# Note: see DerivePointerAlignment too, as it takes precedence
PointerAlignment: Left
RawStringFormats:
- Delimiter: pb
- Delimiters: [pb]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does this change do and why was it required?

Copy link

@Arie001 Arie001 May 10, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not my change but let me explain the pwm driver used up until now is a 40$ part the LM298N module is is a 2$ part it is not 10amps but even if you use a https://www.cytron.io/p-10amp-5v-30v-dc-motor-driver it is 10$ . To me dropping bom cost by 30$ or 35$ is a good reason.

As this is community Funded you need to Lower the BOM as far as possible.

Using 20$ pcbs for the TI sensor not 60$ Using PWM PCB that are High Volume not made
for REX Robotics for kids

https://www.cytron.io/p-10amp-5v-30v-dc-motor-driver 10$ (My option)
https://www.4project.co.il/product/l298n-module 5$ ( I do not know if 2amp will do)
2$ from Aliexpress type places.
https://www.revrobotics.com/rev-11-1200/ 40$

Note The Two Top option need PWM on 2 pins and care to create dead time . It Saves 30-35$ on the BOM . The Two Top options are far more of the Shelf Items.

Sorry For the Slow reply. Take a good look at this Project and the BOM costs
https://scitechdaily.com/easy-to-build-75-open-source-arduino-ventilator-with-high-quality-performance/ (it is CPAP I doubt the include the mask in 75$)

Note Today the funds to make 20 units stands on 4260$ Just over 200$ .two weeks into the campaign. To save 600$ on the 20 units for me is worth while and also off the mass produced if they get made.

Note 3v Level shift has been added to the pcb

Language: TextProto
BasedOnStyle: google
ReflowComments: true
Expand Down
56 changes: 50 additions & 6 deletions 3-Software/Arduino/ventilation_machine/ventilation_machine.ino
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,12 @@ Use the Rate potentiometer to move the arm up/down.
# define pin_AD 13 // Amp Down - not used when you have potentiometers
# define pin_AU 13 // Amp Up - not used when you have potentiometers
# define curr_sense false // o no current sensor
# define control_with_pot true // 1 = control with potentiometers 0 = with push buttons
# define control_with_pot true // 1 = control with potentiometers 0 = with push butto
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Revert

# define FF 10 // motion control feed forward
# define KP 3 // motion control propportional gain
#>>>>>>> master
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Conflicts leftovers

# define KI 1 // motion control integral gain
# define integral_limit 5 // limits the integral of error
# efine integral_limit 5 // limits the integral of error
# define f_reduction_up_val 0.80 // reduce feedforward by this factor when moving up
#else
// FULL_CONFIGURATION == false: no potentiometers for User Interface, feedback pot on pulley.
Expand Down Expand Up @@ -161,7 +162,13 @@ Use the Rate potentiometer to move the arm up/down.
#define pin_FRQ 3 // analog pin of rate potentiometer control
#define pin_PRE 6 // analog pin of pressure potentiometer control

// Talon SR or SPARK controller PWM settings ("angle" for Servo library)
// L298N specific
#define L298N false
#define pin_SPEED 7 // analog
#define pin_FORWARD 5 // digital
#define pin_BACK 3 // digital

// Talon SR or SPARK controller PWM settings ("angle" for Servo library
#define PWM_mid 93 // was 93 - mid value for PWM 0 motion - higher pushes up
#define PWM_max 85
#define PWM_min -85
Comment on lines +165 to 174
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Insert the motor's def to #if statement so the unnecessary definitions won't be compiled

Expand Down Expand Up @@ -362,19 +369,32 @@ enum main_states state;
/// @return None
void setup()
{
if (L298N)
{
pinMode(pin_SPEED, OUTPUT);
pinMode(pin_FORWARD, OUTPUT);
pinMode(pin_BACK, OUTPUT);
}

pinMode(pin_PWM, OUTPUT);
pinMode(pin_FD, INPUT_PULLUP);
pinMode(pin_FU, INPUT_PULLUP);
pinMode(pin_AD, INPUT_PULLUP);
pinMode(pin_AU, INPUT_PULLUP);
pinMode(PIN_SW2, INPUT_PULLUP);
pinMode(pin_TST, INPUT_PULLUP);
pinMode(pin_LED_AMP, OUTPUT);
pinMode(pin_LED_FREQ, OUTPUT);
pinMode(pin_LED_Fail, OUTPUT);
pinMode(pin_USR, OUTPUT);
Comment on lines +386 to +389
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Those aren't supposed to exist anymore

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nimrod Nimrod
Pin 5 is defined a Alarm reset It cannot be a PWM output .

define pin_RST 5
define pin_FORWARD 5

if (!L298N)
{
motor.attach(pin_PWM);
}
pinMode(pin_LED_RED, OUTPUT);
pinMode(pin_LED_GREEN, OUTPUT);
// pinMode(pin_LED_BLUE, OUTPUT); //TODO: Return if needed
pinMode(pin_LED_USR, OUTPUT);
motor.attach(pin_PWM);

Serial.begin(115200);
Serial.print("\nAmboVent Version: ");
Serial.println(VERSION_STR);
Expand Down Expand Up @@ -1009,7 +1029,31 @@ void set_motor_PWM(float wanted_vel_PWM)
if (wanted_vel_PWM < PWM_min)
wanted_vel_PWM = PWM_min; // limit PWM
motorPWM = PWM_mid + int(wanted_vel_PWM);
motor.write(motorPWM);

if (L298N)
{
if (motorPWM > PWM_mid + 3)
{ // leave a -3 to +3 stop range
digitalWrite(pin_FORWARD, HIGH);
digitalWrite(pin_BACK, LOW);
}
else if (motorPWM < PWM_mid - 3)
{ // leave a -3 to +3 stop range
digitalWrite(pin_FORWARD, LOW);
digitalWrite(pin_BACK, HIGH);
}
else
{
digitalWrite(pin_FORWARD, LOW);
digitalWrite(pin_BACK, LOW);
}

analogWrite(pin_SPEED, map(motorPWM, PWM_min, PWM_max, 0, 25));
}
else
{
motor.write(motorPWM);
}
}

int read_motion_for_calib()
Expand Down