Skip to content
Snippets Groups Projects
Commit 60251dfa authored by Martin Vítek's avatar Martin Vítek
Browse files

Hacks to make it work

parent 283048a4
No related branches found
No related tags found
No related merge requests found
......@@ -48,7 +48,7 @@ Controller::Controller(): servo(&DDRB, PB1, &OCR1A, blue_servo_data),
//ADC ini
DDRC = 0;
PORTC = 0;
ADMUX = /*(1<<REFS1) | */(1<<REFS0);
ADMUX = (1<<REFS1) | (1<<REFS0);
ADCSRA = (1<<ADEN) | (1<<ADIE) | (1<<ADPS2) | (1<<ADPS1) | (1<<ADPS0);
//adc.set_reference_voltage(adc.INTERNAL_REFERENCE); //2.56V
//adc.set_prescaler(adc.PRESCALER_128); //115kHz
......@@ -69,7 +69,7 @@ Controller::Controller(): servo(&DDRB, PB1, &OCR1A, blue_servo_data),
sei();
servo.set_angle(OPEN_POSITION);
servo.set_angle(CLOSE_POSITION);
}
void Controller::gate_handler()
......@@ -118,15 +118,15 @@ void Controller::opening_piston()
void Controller::waiting_for_closing_current()
{
if (current_positive > ON_TRESHOLD)
if ((current_negative > ON_TRESHOLD) && (current_negative < 1020))
{
gate_mode = WAITING_FOR_CURRENT_REVERSATION;
gate_mode = WAITING_FOR_CURRENT_DROP;
}
}
void Controller::waiting_for_current_reversation()
{
if (current_negative > ON_TRESHOLD)
if (current_positive > ON_TRESHOLD)
{
gate_mode = WAITING_FOR_CURRENT_DROP;
}
......
......@@ -18,8 +18,8 @@ class Controller
enum current_tresholds
{
OFF_TRESHOLD = 200,
ON_TRESHOLD = 500
OFF_TRESHOLD = 20,
ON_TRESHOLD = 300
};
enum stabilization_tresholds
......
......@@ -13,10 +13,11 @@ int main()
for(;;)
{
controller.gate_handler();
if (controller.debug_delay >= 75) //3Hz
if (controller.debug_delay >= 55) //3Hz
{
controller.gate_handler();
controller.print_debug();
controller.debug_delay = 0;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment