We've all struggled with troubleshooting microcontroller projects
- Probing individual IO pins with a multimeter
- Measuring voltages from analog sensors before implementing ADC dependent logic
- Replacing digital(I2C) sensors because you suspect they're incommunicado, and don't have an oscilloscope at hand
... and so on
The KuttyPy approach fixes that for you by being a more powerful bootloader that also acts as a debugging utility, and comes with a powerful companion graphical app.
The kuttyPy hardware is an ATMEGA32 microcontroller development board developed by the ExpEYES project. The hardware contains the kuttyPy firmware, but can also be used to run other programs via its bootloader functionality. The software is being extended to support other microcontroller platforms as well, such as the 328p found on Arduino Nano boards.
setReg and getReg Python function calls act as debugging and monitoring tools, and combined with Python’s visualization and analytical utilities, this approach has immense pedagogical potential for beginners to the microcontroller world.
Head over to the links on the project homepage for complete docs, or visit the Website Link
Lighning Talk delivered at Scipy.in, IIT B : https://static.fossee.in/scipy2019/SciPyTalks/SciPyIndia2019_S010I_Lightning_Talk_09_20191130.mp4
An example of basic Python based interaction:
from kuttyPy import * #Import the library. also automatically connects to any available kuttypy hardware.
setReg('DDRD',160) #0b10100000 PD7(BLUE LED) and PD5(GREEN LED) made output type
setReg('PORTD',160) # PD5 and PD7 set to HIGH. Both LEDs start glowing
Please note that Python code is not executing on the uC itself. The uC merely has a state machine to manipulate registers based on input received from a computer/laptop/phone running an appropriate app.
This approach was extrapolated to build a full fledged graphical interface with Qt, to control all the features of the Atmega uC .
The simple Atmega32 processor is now capable of the following:
- You can monitor every input
- Toggle every output
- Deal with Peripherals such as PWMs and Counters
- View ADC readings via an analog gauge
- Scan for sensors connected to the I2C Bus
- Monitor readings from sensors [TSL2561 luminosity, and MPU6050 IMU supported]
What can I use it for?¶
- It’s an atmega32 development board with a bootloader supporting the ‘arduino’ protocol
- The bootloader also allows real-time manipulation of registers through commmands sent via the serial port.
- This is done by the associated Python library and companion GUI
- You can monitor every input
- Toggle every output
- Deal with Peripherals such as PWMs and Counters
- View ADC readings via an analog gauge
- Scan for sensors connected to the I2C Bus
- Monitor readings from sensors
- Compile code to hex with the avr-gcc compiler
- Upload hex via the built-in uploader
- Rapidly prototype and debug educational projects. For example, you can verify ADC input values before handing over control to the uploaded hex file which will likely have very limited debugging capabilities.
- Learn how registers are the key to microcontroller operation, as opposed to the Arduino ecosystem which prefers obfuscation of these details underneath abstraction layers.
Python library and Graphical utility¶
The graphical window featured in the cover animation allows exploring the functions of each pin of the hardware live, and also
viewing the corresponding register manipulations executed for each change. This knowledge can then be applied while writing C programs.