Commit 3d27b5f9 authored by tsharith's avatar tsharith
Browse files

Fixed dumb bugs for voltage, reading, temp transitions

parent 6767dc09
......@@ -7,18 +7,6 @@ uint tempC=0;
void Timer1_IRQHandler( void ){
move_forward(100);
*((uint32_t*) 0x40050014) = 0xffff9a65;
/*
if(states_remaining!=0){
MSS_TIM1_init(MSS_TIMER_ONE_SHOT_MODE);
MSS_TIM1_load_immediate(timerPeriod);
MSS_TIM1_start();
MSS_TIM1_enable_irq();
}
if(states_remaining == 0) {
MSS_TIM1_stop();
MSS_GPIO_set_outputs(0);
}
*/
MSS_TIM1_clear_irq();
}
......@@ -126,9 +114,11 @@ void closeSB (ScaffoldingBot * sb)
else if (sb->p) free(p);
}
SB * sbot;
int main()
{
SB * sbot = malloc(sizeof(SB));
sbot = malloc(sizeof(SB));
int exit = 0;
while(!exit)
......@@ -151,15 +141,18 @@ int main()
switch(sbot->print_sel)
{
case CUBE:
cube();
cube();
sbot->status = PRINT;
break;
case TOWER:
tower();
sbot->status = PRINT;
break;
case: WALLS:
walls();
sbot->status = PRINT;
break;
default:
......@@ -173,7 +166,7 @@ int main()
set_hotend_switch(sbot->p, 1);
set_hotend_fan(sbot->p,1);
extrude(sbot->p, -5);
while(readingToVoltage(get_raw_thermistor(sbot->p)) > 110)
while(voltageToTemp(readingToVoltage(get_raw_thermistor(sbot->p))) > 110)
{
}
extrude(sbot->p, -100);
......
......@@ -9,18 +9,18 @@
#define PRINTING_H_
#include "drivers/mss_ace/mss_ace.h"
#define E_STEPS_PER_MM 837
#define E_STEPS_PER_MM 50
// UTILITY
int get_Temp(double voltage){
int voltageToTemp(double voltage){
if(voltage>2.109) return -84.532*voltage+327.26;
else {
return 289.87*exp(-0.353*voltage);
}
}
int getVoltage(double temp){
int tempToVoltage(double temp){
if(temp > 148.982) return (temp - 327.26)/(-84.532);
else {
return log(temp/(289.87))/(-0.353);
......@@ -94,7 +94,7 @@ void init_print(Printing *p)
// HOTEND
*(uint32_t*)((uint32_t)p->HE_Base + AUTO) = 0;
*(uint32_t*)((uint32_t)p->HE_Base + SP) = p->heating_setpoint;
*(uint32_t*)((uint32_t)p->HE_Base + SP) = voltageToReading(tempToVoltage(p->heating_setpoint));
*(uint32_t*)((uint32_t)p->HE_Base + SW) = 0;
*(uint32_t*)((uint32_t)p->HE_Base + FAN) = 0;
*(uint32_t*)((uint32_t)p->HE_Base + SENSITIVITY) = p->heat_ctrl_sensitivity;
......@@ -121,9 +121,9 @@ void set_hotend_auto(Printing *p,char on_off)
*(uint32_t*)((uint32_t)p->HE_Base + AUTO) = on_off;
}
void set_hotend_sp(Printing *p,uint32_t scaled_sp)
void set_hotend_sp(Printing *p,uint32_t temp)
{
*(uint32_t*)((uint32_t)p->HE_Base + SP) = scaled_sp;
*(uint32_t*)((uint32_t)p->HE_Base + SP) = voltageToReading(tempToVoltage(temp));
}
void set_hotend_switch(Printing *p,char on_off)
......@@ -154,7 +154,7 @@ char get_hotend_auto(Printing *p)
uint32_t get_hotend_sp( Printing *p)
{
return *(uint32_t*)((uint32_t)p->HE_Base + SP);
return voltageToTemp(readingToVoltage(*(uint32_t*)((uint32_t)p->HE_Base + SP)));
}
char get_hotend_fan( Printing *p)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment