Single dongle configuration didn’t suffer from the bug. It always syncs the first frame. But the following improvements for all configurations have been made:
Power on camera without crash
Shortened stop recording delay
I2C and serial command data collisions are well prevented
Example Videos
The following two videos are shoot in no master configuration as in the next figure:
In the videos above you can see a stopwatch command is running in the window (precisely, the laptop is a Mac OSX machine and the command is while :; do gdate +%s.%6N; done
to show the current system time again and again in microsecond accuracy).
Using the videos you can check all frames from the first are synced. And if you are very cautious the video by GoPro #2 has extra one frame at the end as compared to the other. But don’t blame MewPro for this extra frame. We can say Dual Hero also sometimes has these kind of extra frames at the end of a footage, and you can safely cut them when editing for your final video products.
Acknowledge
The bug was firstly found by the researchers at Shandong Univ – Virginia Tech (SDU-VT) team. And also some other university researchers and professional videographers pointed out the bug but it was very difficult to fix for us until recently.
Note: The SDU-VT team told us that they published a result obtained by using MewPros:
Matt J. Bender, Hunter G. McClellandy, Andrew Kurdilaz, and Rolf Müller, “Recursive Bayesian Estimation of Bat Flapping Flight Using Kinematic Trees”, AIAA Modeling and Simulation Technologies Conference, 2016-0945, 4-8 January 2016, San Diego, California, USA. http://arc.aiaa.org/doi/abs/10.2514/6.2016-0945 (see VI. Acknowledgements section as there is a mention to MewPro 🙂 )
HVprog2 is an Atmel STK500 clone for programming in HVSP/PP, ISP, TPI, and PDI. This post explains how to use HVprog2.
Note: This and the previous posts are nothing to do with GoPro nor genlock. These discuss some programmers for AVR microcontrollers.
In the previous post we showed a hardware/software mod of original Atmel STK500. Inspired both by Atmel STK500 and its mod we designed a clone programmer called HVprog2.
There already exists another hardware clone of Atmel STK500 whose name is HVprog, and it claims to be able to program in HVSP/PP and ISP. HVprog2 is an improved version of HVprog, thus it has a similar name, and it can actually program AVR chips not only in HVSP/PP and ISP but also in TPI and PDI.
Comparison With STK500 original/mod, HVprog and HVProg2
The below is a comparison chart of AVR programmers:
Note 1: STK500 mod is simply made of original STK500 with few chips removed/replaced.
Note 2: We can use Atmel official firmware if the microcontroller is ATmega8535 but TPI/PDI is not possible in this case. If the microcontroller is one of ATmega16/32/64/128 or ATmega164/324/644/1284 then not only HVSP/PP and ISP but also TPI/PDI is possible by using ScratchMonkey firmware.
Note 3: In order to recover the reset disable fuse the target voltage must be controlled. HVprog lacks the circuit for this, thus it’s impossible to unprogram the fuse bit. Moreover, examining STK500 and HVprog schematics we can find the former inverts XTAL1 signal but the latter where the same firmware is used. As a result, the inversion cause timing problems in every session and makes HVprog unreliable.
HVprog2 Overview
Here is the schematic of HVprog2:
If you are going to use ScratchMonkey exclusively then IC2 74HC165 and its bypass capacitor C3 can be omitted. These parts are for hardware version identification only by Atmel’s firmware.
We recommend you to use a DIP IC socket for IC1 because it enables upgrading/swapping the microcontroller in the future.
The PCB is designed for thru-hole electronic parts wherever available, and is easy to assemble/solder.
The 6 pins marked JP1 (top right) are for PC connection conveniently aligned for using ubiquitous Sparkfun FTDI breakout board or its clone: If you use 5V version of the breakout then the whole HVprog2 programmer runs in 5V logic, and this is necessary to program in HVSP/PP or TPI. Or using Sparkfun’s 3.3V version then HVprog2 is also in 3.3V logic that matches PDI programming.
The 20 pins marked HV_PROG (bottom right) are for target connections. These pins are ordered to be compatible with those of AVR Dragon. This means we can refer AVR Dragon’s comprehensible documentation for wiring/breadboarding in HVSP/PP.
Software
To burn a software JP2 on HVprog2 board must be set to 1-2 (SELF). Then connecting another ISP programmer to 6 pins marked ISP (near center left) will do the job.
As already stated in the above there are currently two possibilities for HVprog2’s firmware depending on which microcontroller is installed:
ATmega8535: Atmel’s firmware for original STK500
ATmegaATmega16/32/64/128 or ATmega164/324/644/1284: ScratchMonkey
Case 1. Atmel’s original firmware is included in any Atmel Studio 4/5/6/7 packages: The name of the binary is STK500.ebn but the file format is not usable with a usual programmer such as avrdude. We need to convert its format “.ebn” to “.hex” using EBN2HEX.exe before burning the binary to the microcontroller (please google and find a download site for EBN2HEX.exe as we cannot find its official webpage). For your information we set ATmega8535’s fuses as S8535C and CKOPT unprogrammed, SPIEN programmed and SUT_CKSEL=”Ext. Crystal/Resonator High Freq; Start-up time: 16K CK + 64ms”.
Case 2. We use ScratchMonkey. The preparation/compile/upload process is the same way described in our previous post.
Target Connections
HVSP/PP. In either Cases, to program in HVSP/PP we can follow the connections to target described in Device Connection Sheets, AVR Dragon’s manual: Refer the connector named HV_PROG.
Note: No need to connect VCC to JTAG as HVprog2 has no such connectors.
ISP. To program in ISP use the ISP connector (JP2 must be set to 2-3).
Note: The VCC pin on HVprog2’s ISP6 connector is always powered by FTDI’s VCC pin.
TPI/PDI. Since HVprog2 is a clone of STK500 or STK500 mod, avrdude requires to be modified as we did in the previous post.
To program a TPI microcontroller two external 510 ohm resistors are required. The HVprog2 board must be powered by 5V version of FTDI breakout board. And use the connection in the following schematic:
5V, MOSI, MISO, SCK, and GND are located at “ISP” connector (JP2 must be set to 2-3). And VTARGET is at pin 19 of “HV_PROG” connector, RESET5V at pin 5 of “HV_PROG”, and RESET12V is at pin 5 of “ISP” or pin 18 of “HV_PROG” connector. Use signals in TPI connector of the schematic if the reset disable fuse is not programmed. Otherwise use signals in TPI HV connector since high voltage TPI requires the target voltage to be controlled.
To program a PDI microcontroller two external 510 ohm resistors are required. The HVprog2 board must be powered by 3.3V version of FTDI breakout board. And use the connection in the following schematic:
(The parts included in dashdots are unnecessary.)
3V3, MOSI, MISO, SCK, and GND are all located at “ISP” connector (JP2 must be set to 2-3).
The post addresses Atmel STK500 starter kit mod as not only HVPP/SP and ISP but also TPI and PDI programmer.
NOTE: This post is nothing to do with GoPro nor Genlock although they are the main topics in this blog.
Introduction
Atmel STK500 is a long-lived product from Year 2001 to now. We consider nowadays most of its users are utilizing it as a simple programmer, and not as starter kit for DIP-package microcontrollers.
STK500 has two microcontrollers ATmega8535L (main) and ATtiny2313V (sub) on its board, and has following features:
HVPP (High Voltage Parallel Programming) programmer
HVSP (High Voltage Serial Programming) programmer
ISP (In-System Programming) programmer
Our mod replaces its main ATmega8535L to a pin-compatible microcontroller that has more flash memory, and removes its sub ATtiny2313V. The latter mod is feasible because since Atmel haven’t offered any new main microcontroller’s firmware after Year 2009 until now sub’s only role of updating main’s firmware is considered to be dead. Once the STK500 board gets a memory-rich microcontroller we can burn an open-source firmware such as ScratchMonkey originally by Matthias Neeracher (modified by Orangkucing Lab) and can also add supports for TPI and PDI.
Hardware Mod
We remove the following four parts from original STK500:
After removing these parts the board looks like the following image:
Then we add the following parts:
U202 : ATmega1284P
R213 : Jumper 0ohm (or solder jumper will do)
J200 : 2×3 header pins
The new microcontroller will be any pin-compatible one to ATmega8535, namely ATmega16/32/64/128 or ATmega164/324/644/1284 families. We used unnecessarily-very-very-high-spec ATmega1284P here because we don’t want to remove/resolder such a delicate SMD chip again in the future.
After soldering these parts STK500 hardware mod has been completed and looks like this:
Software
To burn a firmware to the main microcontroller sit on U202 another ISP programmer is required. We don’t explain here in detail how to upload a firmware or what is an ISP programmer or so since many reader of this post already know these kind of things better than us. 🙂
So just connect another ISP programmer to newly installed J200 pin header and burn the firmware obtained from here (this link is ScratchMonkey’s fork of us but we expect our branch will be pulled and merged to the trunk soon).
If you like to compile the source code using Arduino IDE then its DIP-40 core (“Mighty Core”) is needed. To do this follow the instruction here. After installation of “Mighty Core”, select Tools and board: “Mighty Core”->your microcontroller, clock: “External 7.3728MHz”, pinout: “Standard pinout”; and compile the source code in IDE, then burn the resulted hex-file to your microcontroller.
And for your information we set microcontroller’s fuses to:
CKDIV8/CKOUT unprogrammed
SPIEN programmed
SUT_CKSEL = FSOSC_16KCK_65MS_XOSC_SLOWPWR
Now the STK500 mod board should be recognized as an original Atmel STK500 by Atmel Studio 4/5/6/7 and by avrdude (as stk500v2 for ISP or stk500pp for HVPP or stk500sp for HVSP).
Moreover it is now usable also as a TPI or PDI programmer. The details will be in the next section.
Using STK500 mod as TPI/PDI programmer — Software
Regrettably Atmel Studio doesn’t recognize STK500 mod as a TPI/PDI programmer. The only way is to apply a patch to avrdude’s source code and always use STK500 mod from avrdude in case you need a TPI/PDI programmer.
The patch for avrdude consists of eight parts:
Since avrdude has been distributed in many forms/versions the patch is for your reference only and it usually cannot be applied automatically by using the patch tool. So it is normal that you need to edit the stk500v2.c file manually by yourself.
The first section (1254,1263) of patch enables PGMTYPE_STK500 for XPROG (TPI and PDI).
The second (3712,3719) and third (3724,3736) sections for calculating flash/eeprom sizes, and the fourth (3795,3801) and fifth (3806,3811) are modified to reporting these sizes to the STK500 mod.
And the rest of patch is for TPI fuse programming that needs “a mystic erase prior to writing”.
Using STK500 mod as TPI/PDI programmer — Connections
After avrdude has been patched you can program any TPI/PDI chips.
To program a TPI microcontroller two external 510 ohm resistors are required. And use the connection in the following schematic:
5V, MOSI, MISO, SCK, and GND are located at J200 ISP6 connector. And VTARGET is at any pin marked “VTG” (jumper “VTARGET” must be set), RESET5V at pin 5 of “PROG DATA”, and RESET12V at “ISP6PIN” or “ISP10PIN” connector. Use signals in TPI connector of the schematic if the reset disable fuse is not programmed. Otherwise use signals in TPI HV connector since high voltage TPI requires the target voltage to be controlled.
To program PDI not only two external 510 ohm resistors but also a quad 5V-tolerant 3-state buffer 74LVX125 are required. And use the connection in the following schematic:
3V3 is at “VADJ” or pin 13 of “EXPAND0” connector (jumper “AREF” must be set), and MOSI, MISO, SCK, and GND are at J200 or “ISP6PIN” or “ISP10PIN”. MOSI_GATE is located at RESET pin of “ISP6PIN” or “ISP10PIN”.
Note: The PDI programming voltage is 3.3V. Since STK500 is in 5V logic some kind of logic level translation is necessary. Thus we tried to use automatic level conversion chips such as MAX3002, GTL2003, TXB0104, and FXMA108 but NONE OF THEM WORKED RELIABLY. It’s a pity we must use a 3-state buffer like 74LVX125. What naive/stupid signals Atmel’s PDI protocol uses!!
Lastly we show example invocations of avrdude:
avrdude -c stk500v2 -p t10 -P /dev/tty.usbXXXXX -vvvv # show detailed transaction and tiny10's signature
avrdude -c stk500v2 -p x128a1 -P /dev/tty.usbXXXXX -U flash:w:hehehe.hex:i # flash hehehe.hex to xmega128a1
where tty.usbXXXXX is the serial port your STK500 mod is connected.
A PC controlled genlock system support is added to Dongle’s source code.
For genlock rigs we’ve offered two configurations, namely
Single Dongle configuration
Double Dongle configuration
and these are described in this post. The latter is usable with PC by connecting MewPro #0 to FTDI serial USB breakout and by sending commands from its console.
To control the whole system from PC, today we added support for
3. no master configuration.
(DTR connection between Dongle #0 and FTDI is for resetting Dongle #0 when uploading a sketch to the dongle or opening the Arduino Monitor in PC.)
As you can see this is the same to the single dongle configuration but GoPro #0 is replaced by Genlock Dongle #0 connected to PC through FTDI serial USB breakout board.
The no master configuration is completely symmetric and everything is PC controllable but there is no master camera that you might be accustomed to push mode/shutter buttons or to browse through menus on LCD.
How To Use No Master Configuration
You should follow the instructions for single dongle configuration first. And don’t forget to prepare/buy one more Genlock Dongle for Genlock Dongle #0 in the figure above.
You must update the dongles with the latest version of Dongle source code that supports no master configuration. It is always available at the GitHub repo.
For dongles the initial value of bool debug and the directive UART_RECEIVER_DISABLE should be set as follows:
bool debug
UART_RECEIVER_DISABLE
Dongle #0
true or false
#undef
Dongle #1
false
#undef or #define
(Bold face is the default in the GitHub source code.)
In this configuration usable commands from PC are those which are listed in the I2C command list and its label contains _BACPAC_.