Merge branch 'sangaboard-v5' into 'new_env_for_hw_serial'
# Conflicts: # src/modules/illumination/illumination.cpp
This commit is contained in:
commit
ffb0b04c03
4 changed files with 64 additions and 12 deletions
|
|
@ -9,7 +9,7 @@
|
||||||
#define MAX_COMMANDS 50
|
#define MAX_COMMANDS 50
|
||||||
#define MAX_MODULES 10
|
#define MAX_MODULES 10
|
||||||
#define MAX_ARGUMENT_LENGTH 20 //used in argument parsing, takes up ram
|
#define MAX_ARGUMENT_LENGTH 20 //used in argument parsing, takes up ram
|
||||||
#define VERSION_STRING "Sangaboard Firmware v1.0-beta"
|
#define VERSION_STRING "Sangaboard Firmware v0.5.0"
|
||||||
#define DEBUG_ON
|
#define DEBUG_ON
|
||||||
|
|
||||||
//module choice
|
//module choice
|
||||||
|
|
|
||||||
|
|
@ -78,17 +78,62 @@ void illumination_setup()
|
||||||
register_module(illumination_commands, NULL);
|
register_module(illumination_commands, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef WIRING_CC_LED
|
||||||
|
|
||||||
|
//these functions are useful testing
|
||||||
|
float multi_read(uint8_t pin, uint16_t reads)
|
||||||
|
{
|
||||||
|
float total = 0;
|
||||||
|
for(uint16_t i = 0; i<reads; i++)
|
||||||
|
total += analogRead(pin);
|
||||||
|
|
||||||
|
return total/reads;
|
||||||
|
}
|
||||||
|
|
||||||
|
void cc_test()
|
||||||
|
{
|
||||||
|
analogReadResolution(12);
|
||||||
|
cc_set_value(0);
|
||||||
|
|
||||||
|
for (float v = 0; v <= 1; v+=0.02)
|
||||||
|
{
|
||||||
|
|
||||||
|
Serial.print(v);
|
||||||
|
Serial.print(" ");
|
||||||
|
cc_set_value(v);
|
||||||
|
Serial.print(" ");
|
||||||
|
delay(2000);
|
||||||
|
float current = multi_read(A0, 1000)/4095.0*3.3;
|
||||||
|
Serial.println(current*1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
cc_set_value(0);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void cc_set(String command)
|
void cc_set(String command)
|
||||||
{
|
{
|
||||||
#ifdef WIRING_CC_LED
|
|
||||||
const uint8_t td = 3; // >= 1.5 us
|
|
||||||
const uint8_t tup = 25; // 1-75 us
|
|
||||||
const uint8_t tdown = 230; //180-300us
|
|
||||||
|
|
||||||
char * args[1];
|
char * args[1];
|
||||||
parse_arguments(args, command, 1);
|
parse_arguments(args, command, 1);
|
||||||
float val = atof(args[0]);
|
float val = atof(args[0]);
|
||||||
|
|
||||||
free(args[0]);
|
free(args[0]);
|
||||||
|
cc_set_value(val);
|
||||||
|
}
|
||||||
|
|
||||||
|
void cc_set_value(float val)
|
||||||
|
{
|
||||||
|
#ifdef WIRING_CC_LED
|
||||||
|
if (val<0)
|
||||||
|
{
|
||||||
|
cc_test();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const uint8_t td = 3; // >= 1.5 us
|
||||||
|
const uint8_t tup = 2; // 1-75 us
|
||||||
|
const uint8_t tdown = 180; //180-300us
|
||||||
|
const uint8_t tstart = 110; //100-150us
|
||||||
|
|
||||||
//reset the device
|
//reset the device
|
||||||
digitalWrite(WIRING_CC_LED, LOW);
|
digitalWrite(WIRING_CC_LED, LOW);
|
||||||
|
|
@ -96,11 +141,11 @@ void cc_set(String command)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
uint8_t setting = val*32;
|
uint8_t setting = val*32;
|
||||||
delayMicroseconds(650);
|
delayMicroseconds(650); //reset device
|
||||||
|
|
||||||
//start sequence
|
//start sequence
|
||||||
digitalWrite(WIRING_CC_LED, HIGH);
|
digitalWrite(WIRING_CC_LED, HIGH);
|
||||||
delayMicroseconds(130);
|
delayMicroseconds(tstart);
|
||||||
|
|
||||||
uint8_t stepd = tup;
|
uint8_t stepd = tup;
|
||||||
uint8_t dir = 1;
|
uint8_t dir = 1;
|
||||||
|
|
@ -112,14 +157,16 @@ void cc_set(String command)
|
||||||
}
|
}
|
||||||
|
|
||||||
//step up
|
//step up
|
||||||
|
uint8_t steps_done =0;
|
||||||
for (uint8_t i=16; i!=setting; i+=dir)
|
for (uint8_t i=16; i!=setting; i+=dir)
|
||||||
{
|
{
|
||||||
digitalWrite(WIRING_CC_LED, LOW);
|
digitalWrite(WIRING_CC_LED, LOW);
|
||||||
delayMicroseconds(stepd);
|
delayMicroseconds(stepd);
|
||||||
digitalWrite(WIRING_CC_LED, HIGH);
|
digitalWrite(WIRING_CC_LED, HIGH);
|
||||||
delayMicroseconds(td);
|
delayMicroseconds(td);
|
||||||
comPort->println("Stepping CC"); //TODO remove debug print
|
steps_done++;
|
||||||
}
|
}
|
||||||
|
Serial.print(steps_done);
|
||||||
#else
|
#else
|
||||||
comPort->println("CC LED not supported");
|
comPort->println("CC LED not supported");
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,8 @@ void illumination_pwm(String command);
|
||||||
void illumination_pwm_freq(String command);
|
void illumination_pwm_freq(String command);
|
||||||
|
|
||||||
void cc_set(String command);
|
void cc_set(String command);
|
||||||
|
void cc_set_value(float val);
|
||||||
|
|
||||||
|
|
||||||
void illumination_setup();
|
void illumination_setup();
|
||||||
extern const Command illumination_commands[];
|
extern const Command illumination_commands[];
|
||||||
|
|
|
||||||
|
|
@ -223,6 +223,9 @@ void stage_mr(String command)
|
||||||
parse_arguments(args, command, 3);
|
parse_arguments(args, command, 3);
|
||||||
EACH_MOTOR
|
EACH_MOTOR
|
||||||
{
|
{
|
||||||
|
if (i>3)
|
||||||
|
continue;
|
||||||
|
|
||||||
displacement[i] = atol(args[i]);
|
displacement[i] = atol(args[i]);
|
||||||
free(args[i]);
|
free(args[i]);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue