Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for CTC and other MBI clones with Mighty1 board. #587

Open
wants to merge 1 commit into
base: development
Choose a base branch
from
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
74 changes: 74 additions & 0 deletions boards/Mighty1/gen_fastio.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# currently unused

n=100

print """
#include <Arduino.h>
#include "fastio.h"


void FastIO::digitalWrite(uint8_t pin,uint8_t value) {
switch(pin) {
"""

for i in xrange(0,n):
print """
#ifdef DIO%(i)d_PIN
case %(i)d:
if(value) DIO%(i)d_WPORT |= _BV(DIO%(i)d_PIN); else DIO%(i)d_WPORT &= ~_BV(DIO%(i)d_PIN);
break;
#endif"""%{"i":i}

print """
default:
break;
}
}
"""
print """
uint8_t FastIO::digitalRead(uint8_t pin) {
switch(pin) {
"""
for i in xrange(0,n):
print """
#ifdef DIO%(i)d_PIN
case %(i)d:
return (DIO%(i)d_RPORT & _BV(DIO%(i)d_PIN)) ? HIGH : LOW;
#endif"""%{"i":i}
print """
default:
return LOW;
}
}
"""

print """
void FastIO::pinMode(uint8_t pin,uint8_t mode) {
switch(pin) {
"""
for i in xrange(0,n):
print """
#ifdef DIO%(i)d_PIN
case %(i)d:
switch(mode) {
case INPUT:
DIO%(i)d_DDR &= ~_BV(DIO%(i)d_PIN);
DIO%(i)d_WPORT &= ~_BV(DIO%(i)d_PIN);
break;
case INPUT_PULLUP:
DIO%(i)d_DDR &= ~_BV(DIO%(i)d_PIN);
DIO%(i)d_WPORT |= _BV(DIO%(i)d_PIN);
break;
default:
DIO%(i)d_DDR |= _BV(DIO%(i)d_PIN);
}
break;
#endif"""%{"i":i}
print """
default:
break;
}
}
"""


Binary file added boards/Mighty1/pins_mightyboard.ods
Binary file not shown.
6 changes: 5 additions & 1 deletion boards/readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,14 @@ gen7 1.0+ version:
Make sure to copy the Arduino.h which is needed to compile on Arduino 1.0.
Replace the original boards.txt with the boards.txt so uploading files works.

Mighty1 version
------------------
arduino tools must be 1.6.12 or greater. See boards manager.

============================

The versions are the Arduino IDE versions not the board versions!

The wiring files are fully compatible with the original files. Only the slow modulo
operator % is replaced by a fast "and" operation.


1 change: 1 addition & 0 deletions doc/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/.~lock.*#
128 changes: 128 additions & 0 deletions doc/createTemperatureLookup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
#!/usr/bin/python
#
# Creates a C code lookup table for doing ADC to temperature conversion
# on a microcontroller
# based on: http://hydraraptor.blogspot.com/2007/10/measuring-temperature-easy-way.html
"""Thermistor Value Lookup Table Generator

Generates lookup to temperature values for use in a microcontroller in C format based on:
http://hydraraptor.blogspot.com/2007/10/measuring-temperature-easy-way.html

The main use is for Arduino programs that read data from the circuit board described here:
http://make.rrrf.org/ts-1.0

Usage: python createTemperatureLookup.py [options]

Options:
-h, --help show this help
--r0=... thermistor rating where # is the ohm rating of the thermistor at t0 (eg: 10K = 10000)
--t0=... thermistor temp rating where # is the temperature in Celsuis to get r0 (from your datasheet)
--beta=... thermistor beta rating. see http://reprap.org/bin/view/Main/MeasuringThermistorBeta
--r1=... R1 rating where # is the ohm rating of R1 (eg: 10K = 10000)
--r2=... R2 rating where # is the ohm rating of R2 (eg: 10K = 10000)
--num-temps=... the number of temperature points to calculate (default: 20)
--max-adc=... the max ADC reading to use. if you use R1, it limits the top value for the thermistor circuit, and thus the possible range of ADC values
"""

from math import *
import sys
import getopt

class Thermistor:
"Class to do the thermistor maths"
def __init__(self, r0, t0, beta, r1, r2):
self.r0 = r0 # stated resistance, e.g. 10K
self.t0 = t0 + 273.15 # temperature at stated resistance, e.g. 25C
self.beta = beta # stated beta, e.g. 3500
self.vadc = 5.0 # ADC reference
self.vcc = 5.0 # supply voltage to potential divider
self.k = r0 * exp(-beta / self.t0) # constant part of calculation

if r1 > 0:
self.vs = r1 * self.vcc / (r1 + r2) # effective bias voltage
self.rs = r1 * r2 / (r1 + r2) # effective bias impedance
else:
self.vs = self.vcc # effective bias voltage
self.rs = r2 # effective bias impedance

def temp(self,adc):
"Convert ADC reading into a temperature in Celcius"
v = adc * self.vadc / 1024 # convert the 10 bit ADC value to a voltage
r = self.rs * v / (self.vs - v) # resistance of thermistor
return (self.beta / log(r / self.k)) - 273.15 # temperature

def setting(self, t):
"Convert a temperature into a ADC value"
r = self.r0 * exp(self.beta * (1 / (t + 273.15) - 1 / self.t0)) # resistance of the thermistor
v = self.vs * r / (self.rs + r) # the voltage at the potential divider
return round(v / self.vadc * 1024) # the ADC reading

def main(argv):

r0 = 10000;
t0 = 25;
beta = 3947;
r1 = 680;
r2 = 1600;
num_temps = int(20);
max_adc = int(1023);

try:
opts, args = getopt.getopt(argv, "h", ["help", "r0=", "t0=", "beta=", "r1=", "r2=", "max-adc=", "num-temps="])
except getopt.GetoptError:
usage()
sys.exit(2)

for opt, arg in opts:
if opt in ("-h", "--help"):
usage()
sys.exit()
elif opt == "--r0":
r0 = int(arg)
elif opt == "--t0":
t0 = int(arg)
elif opt == "--beta":
beta = int(arg)
elif opt == "--r1":
r1 = int(arg)
elif opt == "--r2":
r2 = int(arg)
elif opt == "--max-adc":
max_adc = int(arg)
elif opt == "--num-temps":
num_temps = int(arg)

increment = int(max_adc/(num_temps-1));

t = Thermistor(r0, t0, beta, r1, r2)

adcs = range(1, max_adc, increment);
# adcs = [1, 20, 25, 30, 35, 40, 45, 50, 60, 70, 80, 90, 100, 110, 130, 150, 190, 220, 250, 300]
first = 1

print "// Thermistor lookup table for RepRap Temperature Sensor Boards (http://make.rrrf.org/ts)"
print "// Made with createTemperatureLookup.py (http://svn.reprap.org/trunk/reprap/firmware/Arduino/utilities/createTemperatureLookup.py)"
print "// ./createTemperatureLookup.py --r0=%s --t0=%s --r1=%s --r2=%s --beta=%s --max-adc=%s" % (r0, t0, r1, r2, beta, max_adc)
print "// r0: %s" % (r0)
print "// t0: %s" % (t0)
print "// r1: %s" % (r1)
print "// r2: %s" % (r2)
print "// beta: %s" % (beta)
print "// max adc: %s" % (max_adc)
print "#define NUMTEMPS %s" % (len(adcs))
print "short temptable[NUMTEMPS][2] = {"

counter = 0
for adc in adcs:
counter = counter +1
if counter == len(adcs):
print " {4*%s, 8*%s}" % (adc, int(t.temp(adc)))
else:
print " {4*%s, 8*%s}," % (adc, int(t.temp(adc)))
print "};"

def usage():
print __doc__

if __name__ == "__main__":
main(sys.argv[1:])
126 changes: 126 additions & 0 deletions doc/createTemperatureLookup.py~
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
#!/usr/bin/python
#
# Creates a C code lookup table for doing ADC to temperature conversion
# on a microcontroller
# based on: http://hydraraptor.blogspot.com/2007/10/measuring-temperature-easy-way.html
"""Thermistor Value Lookup Table Generator

Generates lookup to temperature values for use in a microcontroller in C format based on:
http://hydraraptor.blogspot.com/2007/10/measuring-temperature-easy-way.html

The main use is for Arduino programs that read data from the circuit board described here:
http://make.rrrf.org/ts-1.0

Usage: python createTemperatureLookup.py [options]

Options:
-h, --help show this help
--r0=... thermistor rating where # is the ohm rating of the thermistor at t0 (eg: 10K = 10000)
--t0=... thermistor temp rating where # is the temperature in Celsuis to get r0 (from your datasheet)
--beta=... thermistor beta rating. see http://reprap.org/bin/view/Main/MeasuringThermistorBeta
--r1=... R1 rating where # is the ohm rating of R1 (eg: 10K = 10000)
--r2=... R2 rating where # is the ohm rating of R2 (eg: 10K = 10000)
--num-temps=... the number of temperature points to calculate (default: 20)
--max-adc=... the max ADC reading to use. if you use R1, it limits the top value for the thermistor circuit, and thus the possible range of ADC values
"""

from math import *
import sys
import getopt

class Thermistor:
"Class to do the thermistor maths"
def __init__(self, r0, t0, beta, r1, r2):
self.r0 = r0 # stated resistance, e.g. 10K
self.t0 = t0 + 273.15 # temperature at stated resistance, e.g. 25C
self.beta = beta # stated beta, e.g. 3500
self.vadc = 5.0 # ADC reference
self.vcc = 5.0 # supply voltage to potential divider
self.k = r0 * exp(-beta / self.t0) # constant part of calculation

if r1 > 0:
self.vs = r1 * self.vcc / (r1 + r2) # effective bias voltage
self.rs = r1 * r2 / (r1 + r2) # effective bias impedance
else:
self.vs = self.vcc # effective bias voltage
self.rs = r2 # effective bias impedance

def temp(self,adc):
"Convert ADC reading into a temperature in Celcius"
v = adc * self.vadc / 1024 # convert the 10 bit ADC value to a voltage
r = self.rs * v / (self.vs - v) # resistance of thermistor
return (self.beta / log(r / self.k)) - 273.15 # temperature

def setting(self, t):
"Convert a temperature into a ADC value"
r = self.r0 * exp(self.beta * (1 / (t + 273.15) - 1 / self.t0)) # resistance of the thermistor
v = self.vs * r / (self.rs + r) # the voltage at the potential divider
return round(v / self.vadc * 1024) # the ADC reading

def main(argv):

r0 = 10000;
t0 = 25;
beta = 3947;
r1 = 680;
r2 = 1600;
num_temps = int(20);
max_adc = int(1023);

try:
opts, args = getopt.getopt(argv, "h", ["help", "r0=", "t0=", "beta=", "r1=", "r2=", "max-adc="])
except getopt.GetoptError:
usage()
sys.exit(2)

for opt, arg in opts:
if opt in ("-h", "--help"):
usage()
sys.exit()
elif opt == "--r0":
r0 = int(arg)
elif opt == "--t0":
t0 = int(arg)
elif opt == "--beta":
beta = int(arg)
elif opt == "--r1":
r1 = int(arg)
elif opt == "--r2":
r2 = int(arg)
elif opt == "--max-adc":
max_adc = int(arg)

increment = int(max_adc/(num_temps-1));

t = Thermistor(r0, t0, beta, r1, r2)

adcs = range(1, max_adc, increment);
# adcs = [1, 20, 25, 30, 35, 40, 45, 50, 60, 70, 80, 90, 100, 110, 130, 150, 190, 220, 250, 300]
first = 1

print "// Thermistor lookup table for RepRap Temperature Sensor Boards (http://make.rrrf.org/ts)"
print "// Made with createTemperatureLookup.py (http://svn.reprap.org/trunk/reprap/firmware/Arduino/utilities/createTemperatureLookup.py)"
print "// ./createTemperatureLookup.py --r0=%s --t0=%s --r1=%s --r2=%s --beta=%s --max-adc=%s" % (r0, t0, r1, r2, beta, max_adc)
print "// r0: %s" % (r0)
print "// t0: %s" % (t0)
print "// r1: %s" % (r1)
print "// r2: %s" % (r2)
print "// beta: %s" % (beta)
print "// max adc: %s" % (max_adc)
print "#define NUMTEMPS %s" % (len(adcs))
print "short temptable[NUMTEMPS][2] = {"

counter = 0
for adc in adcs:
counter = counter +1
if counter == len(adcs):
print " {4*%s, 8*%s}" % (adc, int(t.temp(adc)))
else:
print " {4*%s, 8*%s}," % (adc, int(t.temp(adc)))
print "};"

def usage():
print __doc__

if __name__ == "__main__":
main(sys.argv[1:])
8 changes: 8 additions & 0 deletions src/ArduinoAVR/Repetier/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/core/
/libraries/
/Release/
/.ino.cpp
/.cproject
/.project
/.settings/
/.pydevproject
Loading