Posted on Leave a comment

CR10 Configure E-Steps With This Gcode File

The code below will heat the hot end nozzle up to 185 and then set the e-steps to 147.19, and then slowly extrude 100mm of filament.

To use it, mark a line 120mm from your extruder on your filament. Run this gcode as if Cura spit it out. Measure the line. You want to be at 20mm when it’s done.

100 / ( 120 – measurement_after_extruding ) * current Esteps = New_Esteps.

The measurement_after_extruding is the distance from your extruder to your line after extruding. You are shooting for 20mm

M82 ;absolute extrusion mode
 ;*** Start Preheating ***
 M104 S185 T0 ; start preheating hotend
 G28 ; home
 M109 S185 T0 ; heat hotend to 185 
 ;*** End Preheating ***
 M220 S100 ;Reset Feedrate
 M221 S100 ;Reset Flowrate
 G28 ;Home
 G92 E0 ;Reset Extruder
 G1 Z20.0 F3000 ;Move Z Axis up
 G92 E0 ;Reset Extruder
 G1 Z10.0 F3000 ;Move Z Axis up
 M92 E147.19; set e-steps to 141
 G92 E0  
 G1 E100 F100   ; Extrude 100mm
 M82 ;absolute extrusion mode
 M104 S0
Posted on Leave a comment

ESP32TimerInterrupt Simple Example

Here’s a stripped down example of Khoi Hoang’s ESP32TimerInterrupt library. The library claims to run up to 16 compares (or alarms) on one, single timer. It seems to work well although I’ve only tested 3 timers thus far. I plan to use it on my Idiot Christmas Light Controller controlling triacs.

include <Arduino.h>
   For ESP32 boards
   Written by Khoi Hoang
 Built by Khoi Hoang
   Licensed under MIT license
 This is the most basic example using Khoi Hoang's ESP32TimerInterrupt library.  
   The library works well, but I found myself wanting an ultra basic version to understand the functionality
 include "ESP32TimerInterrupt.h"
 // Change these to whatever GPIO you'd like to toggle
 define LED0 25 // GPIO 25
 define LED1 27 // GPIO 27
 define LED2 33 // GPIO 33
 // The lenght of each timer in milliseconds
 define TIMER0_INTERVAL_MS 100
 define TIMER1_INTERVAL_MS 3000
 define TIMER2_INTERVAL_MS 400
 void IRAM_ATTR TimerHandler0(void)
   static bool toggle0 = false;
 //timer interrupt toggles pin LED0
   digitalWrite(LED0, toggle0);
   toggle0 = !toggle0;
 void IRAM_ATTR TimerHandler1(void)
   static bool toggle1 = false;
 //timer interrupt toggles LED1
   digitalWrite(LED1, toggle1);
   toggle1 = !toggle1;
 void IRAM_ATTR TimerHandler2(void)
   static bool toggle2 = false;
 //timer interrupt toggles LED2
   digitalWrite(LED2, toggle2);
   toggle2 = !toggle2;
 // Init ESP32 timer 0,1, and 2
 ESP32Timer ITimer0(0);
 ESP32Timer ITimer1(1);
 ESP32Timer ITimer2(2);
 void setup()
 pinMode(LED0, OUTPUT);
   pinMode(LED1, OUTPUT);
   pinMode(LED2, OUTPUT);
   while (!Serial)
 Serial.print(F("\nStarting TimerInterruptTest on "));
 Serial.print(F("CPU Frequency = "));
   Serial.print(F_CPU / 1000000);
   Serial.println(F(" MHz"));
 // Using ESP32  => 80 / 160 / 240MHz CPU clock ,
   // For 64-bit timer counter
   // For 16-bit timer prescaler up to 1024
 // Setup Timer0
   // Interval in microsecs
   if (ITimer0.attachInterruptInterval(TIMER0_INTERVAL_MS * 1000, TimerHandler0))
     Serial.print(F("Starting  ITimer0 OK, millis() = "));
     Serial.println(F("Can't set ITimer0. Select another freq. or timer"));
 // Setup Timer1
   // Interval in microsecs
   if (ITimer1.attachInterruptInterval(TIMER1_INTERVAL_MS * 1000, TimerHandler1))
     Serial.print(F("Starting  ITimer1 OK, millis() = "));
     Serial.println(F("Can't set ITimer1. Select another freq. or timer"));
 // Setup Timer2
   // Interval in microsecs
   if (ITimer2.attachInterruptInterval(TIMER2_INTERVAL_MS * 1000, TimerHandler2))
     Serial.print(F("Starting  ITimer2 OK, millis() = "));
     Serial.println(F("Can't set ITimer1. Select another freq. or timer"));
 void loop()
Posted on Leave a comment

LtSpice Potentiometer Model

It takes about 20 seconds to put a potentiometer model in LtSpice. I have no idea why it wasn’t included. Regardless….

— Download the “Pot” folder at

— Find your C:\Users\YOUR_USERNAME\Documents\LTspiceXVII\lib\ folder
— Place pot.asy in your “sym” folder. C:\Users\YOUR_USERNAME\Documents\LTspiceXVII\lib\sym\
— Place pot.sub in your “sub” folder. C:\Users\YOUR_USERNAME\Documents\LTspiceXVII\lib\ sub\
— Click the text tool. Select “SPICE Directive” and paste in .include pot.sub.
— Restart LTspice
— Creat a new schematic. Press F2. You should see “Pot”.

The wiper is on a 0-1 scale. 1 = 100%. 0.5 = 50%.
There is a glitch that occurs if a resistor is 0 ohms in LtSpice. So, this pot actually is limited from 0.001 – 0.999 so don’t freak out if your values are off by 0.1% on extreme settings.

Posted on Leave a comment

MIDI Test Code on Arduino and STM32 Blue Pill

This code turns the onboard PC13 LED of the STM32 Blue Pill on when a MIDI NoteOn message is received and turns the LED off when a MIDI Noteoff message is received. It’s my preferred way to confirm that a MIDI circuit is working. It relies on the Arduino MIDI Library.

#include <MIDI.h>

#define LED PC13 // LED pin on Arduino Uno


void doSomeStuffWithNoteOn(byte channel, byte pitch, byte velocity);
void NoteOff(byte channel, byte note, byte velocity);

void setup()
  pinMode(LED, OUTPUT);

void loop()

void doSomeStuffWithNoteOn(byte channel, byte pitch, byte velocity)
  // note on code goes here
  digitalWrite(PC13, LOW);

void NoteOff(byte channel, byte note, byte velocity)
  // note off code goes here
  digitalWrite(PC13, HIGH);