Permalink
Browse files

Merge release-candidate-triffid branch

  • Loading branch information...
1 parent eca4b0b commit 096d7dfdf3697159bf5cd06a4420471348ea68b1 @triffid triffid committed Jan 7, 2011
Showing with 2,678 additions and 1,783 deletions.
  1. +73 −56 Makefile
  2. +40 −31 README
  3. +64 −30 analog.c
  4. +0 −17 analog_sim.c
  5. +5 −5 arduino.h
  6. +365 −1 arduino_1280.h
  7. +100 −1 arduino_168_328p.h
  8. +153 −17 arduino_644.h
  9. +38 −67 clock.c
  10. +2 −27 clock.h
  11. +0 −56 clock_sim.c
  12. +329 −159 config.h.dist
  13. +5 −2 copier.c
  14. +215 −185 dda.c
  15. +6 −0 dda.h
  16. +36 −23 dda_queue.c
  17. +3 −0 dda_queue.h
  18. +2 −0 delay.h
  19. +0 −15 delay_sim.c
  20. +8 −9 func.sh
  21. +22 −38 gcode_parse.c
  22. +24 −22 gcode_parse.h
  23. +201 −168 gcode_process.c
  24. +13 −0 gcode_process.h
  25. +203 −59 heater.c
  26. +9 −30 heater.h
  27. +71 −75 mendel.c
  28. +0 −1 mendel_cmd
  29. +312 −0 mendel_cmd
  30. +2 −6 serial.h
  31. +0 −116 serial_sim.c
  32. +16 −13 sersendf.c
  33. +1 −4 sersendf.h
  34. +0 −105 simulation.c
  35. +0 −84 simulation.h
  36. +233 −167 temp.c
  37. +13 −45 temp.h
  38. +100 −84 timer.c
  39. +14 −15 timer.h
  40. +0 −50 timer_sim.c
View
@@ -4,40 +4,37 @@
# #
# by Triffid Hunter, Traumflug, jakepoz #
# #
-##############################################################################
-
-##############################################################################
# #
-# Change these to suit your application #
+# This firmware is Copyright (C) 2009-2010 Michael Moon aka Triffid_Hunter #
# #
-##############################################################################
-
-PROGRAM = mendel
-
-SOURCES = $(PROGRAM).c serial.c dda.c gcode_parse.c gcode_process.c clock.c timer.c temp.c sermsg.c dda_queue.c watchdog.c debug.c sersendf.c heater.c analog.c delay.c
-
-##############################################################################
+# This program is free software; you can redistribute it and/or modify #
+# it under the terms of the GNU General Public License as published by #
+# the Free Software Foundation; either version 2 of the License, or #
+# (at your option) any later version. #
# #
-# Change these to suit your hardware #
+# This program is distributed in the hope that it will be useful, #
+# but WITHOUT ANY WARRANTY; without even the implied warranty of #
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
+# GNU General Public License for more details. #
+# #
+# You should have received a copy of the GNU General Public License #
+# along with this program; if not, write to the Free Software #
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #
# #
##############################################################################
-#MCU_TARGET = atmega168
-MCU_TARGET = atmega328p
-#MCU_TARGET = atmega644p
-#MCU_TARGET = atmega1280
-F_CPU = 16000000L
-
##############################################################################
# #
-# These defaults should be ok, change if you need to #
+# Change these to suit your hardware #
# #
##############################################################################
-ARCH = avr-
-CC = $(ARCH)gcc
-OBJDUMP = $(ARCH)objdump
-OBJCOPY = $(ARCH)objcopy
+# MCU_TARGET = atmega168
+# MCU_TARGET = atmega328p
+MCU_TARGET = atmega644p
+# MCU_TARGET = atmega1280
+
+# F_CPU = 16000000L
##############################################################################
# #
@@ -51,16 +48,25 @@ OBJCOPY = $(ARCH)objcopy
# enables reprap-style acceleration #
# ACCELERATION_RAMPING #
# enables start/stop ramping #
+# ACCELERATION_TEMPORAL #
+# enables experimental temporal step algorithm - not technically a type of #
+# acceleration, but since it controls step timing it seems appropriate #
+# GEN3 #
+# build for standard reprap electronics instead of your custom rig #
+# HOST #
+# this is the motherboard for GEN3- don't touch! Extruder has its own #
+# Makefile. #
# #
##############################################################################
-DEFS = -DF_CPU=$(F_CPU)
+# DEFS = -DF_CPU=$(F_CPU) -DHOST -DGEN3
# DEFS += "-DDEBUG=1"
-OPTIMIZE = -Os -ffunction-sections -finline-functions-called-once
-# OPTIMIZE = -O0
-CFLAGS = -g -Wall -Wstrict-prototypes $(OPTIMIZE) -mmcu=$(MCU_TARGET) $(DEFS) -std=gnu99 -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -save-temps
-LDFLAGS = -Wl,--as-needed -Wl,--gc-sections
+##############################################################################
+# #
+# Programmer settings for "make program" #
+# #
+##############################################################################
AVRDUDE = avrdude
AVRDUDECONF = /etc/avrdude.conf
@@ -73,12 +79,35 @@ AVRDUDECONF = /etc/avrdude.conf
# MODE="0660" #
# #
##############################################################################
+
PROGPORT = /dev/arduino
+
# atmega168
#PROGBAUD = 19200
# atmega328p, 644p, 1280
PROGBAUD = 57600
+
+##############################################################################
+# #
+# These defaults should be ok, change if you need to #
+# #
+##############################################################################
+
+PROGRAM = mendel
+
+SOURCES = $(PROGRAM).c serial.c dda.c gcode_parse.c gcode_process.c timer.c temp.c sermsg.c dda_queue.c watchdog.c debug.c sersendf.c heater.c analog.c delay.c intercom.c pinio.c clock.c
+
+ARCH = avr-
+CC = $(ARCH)gcc
+OBJDUMP = $(ARCH)objdump
+OBJCOPY = $(ARCH)objcopy
+
+OPTIMIZE = -Os -ffunction-sections -finline-functions-called-once -mcall-prologues
+# OPTIMIZE = -O0
+CFLAGS = -g -Wall -Wstrict-prototypes $(OPTIMIZE) -mmcu=$(MCU_TARGET) $(DEFS) -std=gnu99 -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -save-temps
+LDFLAGS = -Wl,--as-needed -Wl,--gc-sections
+
OBJ = $(patsubst %.c,%.o,${SOURCES})
.PHONY: all program clean size
@@ -93,23 +122,32 @@ program: $(PROGRAM).hex config.h
$(AVRDUDE) -cstk500v1 -b$(PROGBAUD) -p$(MCU_TARGET) -P$(PROGPORT) -C$(AVRDUDECONF) -U flash:w:$^
stty 115200 raw ignbrk -hup -echo ixoff < $(PROGPORT)
+program-fuses:
+ avr-objdump -s -j .fuse mendel.o | perl -ne '/\s0000\s([0-9a-f]{2})/ && print "$$1\n"' > lfuse
+ avr-objdump -s -j .fuse mendel.o | perl -ne '/\s0000\s..([0-9a-f]{2})/ && print "$$1\n"' > hfuse
+ avr-objdump -s -j .fuse mendel.o | perl -ne '/\s0000\s....([0-9a-f]{2})/ && print "$$1\n"' > efuse
+ $(AVRDUDE) -cstk500v1 -b$(PROGBAUD) -p$(MCU_TARGET) -P$(PROGPORT) -C$(AVRDUDECONF) -U lfuse:w:lfuse
+ $(AVRDUDE) -cstk500v1 -b$(PROGBAUD) -p$(MCU_TARGET) -P$(PROGPORT) -C$(AVRDUDECONF) -U hfuse:w:hfuse
+ $(AVRDUDE) -cstk500v1 -b$(PROGBAUD) -p$(MCU_TARGET) -P$(PROGPORT) -C$(AVRDUDECONF) -U efuse:w:efuse
+
clean:
- rm -rf *.o *.elf *.lst *.map *.sym *.lss *.eep *.srec *.bin *.hex *.al *.i *.s *~
- rm -f sim
+ rm -rf *.o *.elf *.lst *.map *.sym *.lss *.eep *.srec *.bin *.hex *.al *.i *.s *~ *fuse
size: $(PROGRAM).elf
@echo " SIZE Atmega168 Atmega328p Atmega644"
- @$(OBJDUMP) -h $^ | perl -ne '/.(text)\s+([0-9a-f]+)/ && do { $$a += eval "0x$$2" }; END { printf " FLASH : %5d bytes (%2d%% of %2dkb) (%2d%% of %2dkb) (%2d%% of %2dkb)\n", $$a, $$a * 100 / (14 * 1024), 14, $$a * 100 / (30 * 1024), 30, $$a * 100 / (63 * 1024), 63 }'
- @$(OBJDUMP) -h $^ | perl -ne '/.(data|bss)\s+([0-9a-f]+)/ && do { $$a += eval "0x$$2" }; END { printf " RAM : %5d bytes (%2d%% of %2dkb) (%2d%% of %2dkb) (%2d%% of %2dkb)\n", $$a, $$a * 100 / (1 * 1024), 1, $$a * 100 / (2 * 1024), 2, $$a * 100 / (4 * 1024), 4 }'
- @$(OBJDUMP) -h $^ | perl -ne '/.(eeprom)\s+([0-9a-f]+)/ && do { $$a += eval "0x$$2" }; END { printf " EEPROM: %5d bytes (%2d%% of %2dkb) (%2d%% of %2dkb) (%2d%% of %2dkb)\n", $$a, $$a * 100 / (1 * 1024), 1, $$a * 100 / (2 * 1024), 2, $$a * 100 / (2 * 1024), 2 }'
+ @$(OBJDUMP) -h $^ | perl -MPOSIX -ne '/.(text)\s+([0-9a-f]+)/ && do { $$a += eval "0x$$2" }; END { printf " FLASH : %5d bytes (%2d%% of %2dkb) (%2d%% of %2dkb) (%2d%% of %2dkb)\n", $$a, ceil($$a * 100 / (15 * 1024)), 15, ceil($$a * 100 / (31 * 1024)), 31, ceil($$a * 100 / (63 * 1024)), 63 }'
+ @$(OBJDUMP) -h $^ | perl -MPOSIX -ne '/.(data|bss)\s+([0-9a-f]+)/ && do { $$a += eval "0x$$2" }; END { printf " RAM : %5d bytes (%2d%% of %2dkb) (%2d%% of %2dkb) (%2d%% of %2dkb)\n", $$a, ceil($$a * 100 / (1 * 1024)), 1, ceil($$a * 100 / (2 * 1024)), 2, ceil($$a * 100 / (4 * 1024)), 4 }'
+ @$(OBJDUMP) -h $^ | perl -MPOSIX -ne '/.(eeprom)\s+([0-9a-f]+)/ && do { $$a += eval "0x$$2" }; END { printf " EEPROM: %5d bytes (%2d%% of %2dkb) (%2d%% of %2dkb) (%2d%% of %2dkb)\n", $$a, ceil($$a * 100 / (1 * 1024)), 1, ceil($$a * 100 / (2 * 1024)), 2, ceil($$a * 100 / (2 * 1024)), 2 }'
config.h: config.h.dist
@echo "Please review config.h, as config.h.dist is more recent."
+ @echo
+ @diff -bBEuF '^. [[:digit:]]. [[:upper:]]' config.h config.h.dist
@false
-%.o: %.c config.h
+%.o: %.c config.h Makefile
@echo " CC $@"
- @$(CC) -c $(CFLAGS) -Wa,-adhlns=$(<:.c=.al) -o $@ $<
+ @$(CC) -c $(CFLAGS) -Wa,-adhlns=$(<:.c=.al) -o $@ $(subst .o,.c,$@)
%.elf: $(OBJ)
@echo " LINK $@"
@@ -130,24 +168,3 @@ config.h: config.h.dist
%.sym: %.elf
@echo " SYM $@"
@$(OBJDUMP) -t $< | perl -ne 'BEGIN { printf " ADDR NAME SIZE\n"; } /([0-9a-f]+)\s+(\w+)\s+O\s+\.(bss|data)\s+([0-9a-f]+)\s+(\w+)/ && printf "0x%04x %-20s +%d\n", eval("0x$$1") & 0xFFFF, $$5, eval("0x$$4")' | sort -k1 > $@
-
-
-##############################################################################
-# #
-# Simulation #
-# #
-##############################################################################
-
-SIM_SOURCES = $(PROGRAM).c serial_sim.c dda.c gcode_parse.c gcode_process.c timer_sim.c clock_sim.c temp.c sermsg.c dda_queue.c debug.c sersendf.c heater.c analog_sim.c delay_sim.c simulation.c
-SIM_HEADERS = config.h serial.h dda.h gcode_parse.h gcode_process.h timer.h clock.h temp.h sermsg.h dda_queue.h debug.h sersendf.h heater.h analog.h delay.h simulation.h
-
-SIM_OBJ = $(patsubst %.c,%.sim.o,${SIM_SOURCES})
-SIM_CFLAGS = -g -Wall -Wstrict-prototypes -Os $(DEFS) -std=gnu99 -funsigned-char -funsigned-bitfields -fshort-enums
-
-%.sim.o: %.c $(SIM_HEADERS)
- @echo " CC $@"
- @cc -DDEBUG -DSIMULATION -Wa,-adhlns=$(<:.c=.al) -c $(SIM_CFLAGS) -o $@ $<
-
-sim: $(SIM_OBJ)
- @echo " LINK $@"
- @cc $(SIM_CFLAGS) -o $@ $^
View
@@ -18,12 +18,27 @@ Rewrite of Reprap Mendel firmware:
2) check programming settings in Makefile
3) make
4) make program
+4a) if programming blank chip, make program-fuses
5) ./sender.sh
6) have a play, go to 1) if not right
7) try printing something!
##############################################################################
# #
+# Requirements #
+# #
+##############################################################################
+
+Compile:
+ gnu make
+ binutils, gcc, etc built for avr target (avr-gcc, avr-as, etc)
+ avr-libc
+Program:
+ avrdude
+ something that avrdude supports: bootloader, separate programmer, whatever
+
+##############################################################################
+# #
# License #
# #
##############################################################################
@@ -98,30 +113,15 @@ The fixed-point stuff is fun, although we have to manually ensure that the decim
The PID code in heater.c is probably quite generalisable, and seems to work well when tuned. Google knows of plenty of PID tuning guides.
-
##############################################################################
# #
-# Simulation #
+# Resources #
# #
##############################################################################
-To compile the simulation code, use
-
- $ make sim
-
-The simulation program will open a serial port for communication. If you don't want to connect a null modem cable, you can use 'socat' to connect a virtual serial port to your terminal:
-
- $ socat -d -d PTY READLINE
- 2010/10/18 20:24:33 socat[3700] N PTY is /dev/pts/2
- 2010/10/18 20:24:33 socat[3700] N using readline on stdin for reading and stdio for writing
- 2010/10/18 20:24:33 socat[3700] N starting data transfer loop with FDs [3,3] and [0,0]
-
-On the first line of output, socat will tell you the name of the virtual serial port. Pass this as an argument to the simulation program (in another terminal):
-
- $ ./sim /dev/pts/2
-
-Now you can send G-codes from the socat terminal. The simulation code will print any data sent via the firmware's serial interface. Stepper positions will be shown in green, counting a rising slope on the pin as one step.
-
+Forum thread: http://forums.reprap.org/read.php?147,33082
+Source Repository: http://github.com/triffid/FiveD_on_Arduino
+Wiki Page: http://objects.reprap.org/wiki/FiveD_on_Arduino
##############################################################################
# #
@@ -132,11 +132,14 @@ Now you can send G-codes from the socat terminal. The simulation code will print
*** analog.[ch]
This is the analog subsystem. Only used if you have a thermistor or ad595
-*** arduino.h
-Pin mappings and helper functions for various arduinos ('168/'328-based and '644-based only so far, feel free to add '1280 and post a patch)
+*** arduino.h, arduino_[chip].h
+Pin mappings and helper functions for various atmegas
*** clock.[ch]
-A system clock for periodic tasks. Supports a long-running clock, but this is disabled by default as nothing uses it (yet!)
+Regular functions that run in main loop rather than an interrupt
+
+*** config.h.dist, config.h
+Configuration for your electronics and hardware. Copy config.h.dist to config.h, edit config.h to suit
*** copier.[ch]
A totally untested and currently unused chunk of code for copying firmware to another identical chip
@@ -150,36 +153,42 @@ The queue of moves received from the host.
*** debug.[ch]
Debugging aids
+*** delay.[ch]
+Delay functions
+
*** FiveD_on_Arduino.pde
Allows firmware to be built in arduino ide
*** func.sh
Lots of host-side shell scripts for talking to firmware
-*** gcode.[ch]
-Gcode interpreter. Scaling of factors to internally used integer or fixed point happens here too.
+*** gcode_parse.[ch]
+Gcode parser. Scaling of factors to internally used integer or fixed point happens here too.
+
+*** gcode_process.[ch]
+Gcodes actually get executed here after being parsed.
*** heater.[ch]
Heater management, including PID and PWM algorithms, and some configuration parameters
-*** machine.h
-Configuration variables to match firmware to your hardware
+*** intercom.[ch]
+Gen3 serial link control and communication
+
+*** LICENSE
+Gnu GPL2 license
*** Makefile
instructions for make on how to build firmware. has a list of modules to build which may need to be updated every so often
*** mendel.c
Firmware startup and main loop code
-*** pinout.h
-This file associates various functions with particular pins on your avr
+*** pinio.h
+A few I/O primitives
*** README
this file
-*** simulation.[sh]
-helper code to run the code on any Unix PC
-
*** sender.sh
A simple talker
Oops, something went wrong.

2 comments on commit 096d7df

@phord
Collaborator
phord commented on 096d7df Mar 12, 2012

I know this is a really old commit. I apologize for bringing it up again. But I noticed this commit removes all the simulation code that is credited in the README.md as "the excellent simulation code". Did it simply make the merge too difficult, or was there some other reason for removing it?

@Traumflug
Owner

No reason for apologies, the removal of the simulation code was probably simply sloppiness. Getting the simulator back would be welcome.

Please sign in to comment.