Thursday, January 26, 2012

Picaxe BASIC Logic Script

Ready to be copied and pasted directly into Picaxe Programmer or AxePAD for simulation


main:
wait 1
sound B.1, (108,50)
wait 2
   for b0 = 0 to 1
high 2
sound B.1, (84,3)
sound B.1, (40,4)
low 1
low 2
pause 165
high 2
sound B.1, (84,3)
sound B.1, (40,3)
low 1
low 2
pause 165
high 2
sound B.1, (84,3)
sound B.1, (40,3)
low 1
low 2
pause 220
high 2
sound B.1, (84,3)
sound B.1, (40,3)
low 1
low 2
pause 420
high 2
sound B.1, (84,3)
sound B.1, (40,5)
low 1
low 2
pause 115
high 2
sound B.1, (74,3)
sound B.1, (28,3)
low 1
low 2
pause 165
high 2
sound B.1, (74,3)
sound B.1, (28,3)
low 1
low 2
pause 165
high 2
sound B.1, (62,3)
sound B.1, (16,3)
low 1
low 2
pause 220
high 2
sound B.1, (62,3)
sound B.1, (16,3)
low 1
low 2
pause 900
   next b0

'Party Rock Anthem 1
tune B.1, 3, 001100,($10,$10,$03,$03,$03,$03,$D3,$13,$51,$53,$D1,$8C,$08,$0A,$10,$08,$03,$0C,$03,$03,$CA,$C8,$8C,$0C,$10,$03,$03,$03,$03,$93,$D1,$8C,$08,$0A,$10,$0A,$08,$0A,$8C,$CC)

sound B.1, (124,2)
sound B.1, (84,2)
sound B.1, (40,2)
low 1
pause 135
sound B.1, (124,2)
sound B.1, (84,2)
sound B.1, (40,2)
low 1
pause 135
wait 2
sound B.1, (127,50)
sound B.1, (16,30)
sound B.1, (127,3000)
'Fail!
tune B.1, 1, 001000,($DB,$60,$62,$66,$63,$98,$60)
low 2
pause 17
high 2
pause 1333
low 2
pause 9
high 2
pause 20
low 2
pause 20
high 2
wait 2
low 2
wait 6
goto rickroll

rickroll:
high 5
pause 5
low 5
'Rollin 1
tune B.1, 3, 001100,($C5,$05,$C7,$07,$C0)
high 5
pause 5
low 5
tune B.1, 3, 001100,($C7,$07,$C9,$09,$50)
high 5
pause 5
low 5
tune B.1, 3, 001100,($4A,$09,$C5,$05,$C7)
high 5
pause 5
low 5
tune B.1, 3, 001100,($07,$C0,$04,$05,$C5)
high 5
pause 5
low 5
tune B.1, 3, 001100,($CC,$45,$05,$45,$CC)
high 5
pause 5
low 5
tune B.1, 3, 001100,($22,$24,$25,$25,$27)
high 5
pause 5
low 5
tune B.1, 3, 001100,($24,$64,$62,$20,$A0)
high 5
pause 5
low 5
tune B.1, 3, 001100,($EC,$2C,$22,$22,$24)
high 5
pause 5
low 5
tune B.1, 3, 001100,($25,$E2,$20,$00,$2C)
high 5
pause 5
low 5
tune B.1, 3, 001100,($00,$27,$A7,$2C,$22)
high 5
pause 5
low 5
tune B.1, 3, 001100,($22,$24,$25,$22,$25)
high 5
pause 5
low 5
tune B.1, 3, 001100,($27,$2C,$24,$22,$20)
high 5
pause 5
low 5
tune B.1, 3, 001100,($E0,$EC,$2C,$22,$22)
high 5
pause 5
low 5
tune B.1, 3, 001100,($24,$25,$22,$E0,$27,$27,$27)
high 5
pause 5
low 5
tune B.1, 3, 001100,($29,$E7,$EC,$A5,$25,$27,$29)
high 5
pause 5
low 5
tune B.1, 3, 001100,($25,$27,$27,$27,$29,$E7,$E0)
high 5
pause 5
low 5
tune B.1, 3, 001100,($AC,$22,$24,$25,$22,$2C,$27,$29,$27,$E7)
high 5
pause 5
low 5
'Strollin1
tune B.1, 3, 001100,($40,$42,$45,$42,$09,$49,$09)
high 5
pause 5
low 5
tune B.1, 3, 001100,($07,$C7,$40,$42,$45,$42,$07)
high 5
pause 5
low 5
tune B.1, 3, 001100,($47,$47,$07,$05,$45,$44,$02)
high 5
pause 5
low 5
tune B.1, 3, 001100,($40,$42,$45,$42,$C5,$07,$04)
high 5
pause 5
low 5
tune B.1, 3, 001100,($44,$42,$C0,$00,$C7,$85,$40,$42,$45,$42)
high 5
pause 5
low 5
tune B.1, 3, 001100,($09,$49,$49,$09,$07,$C7,$40,$42,$45,$42)
high 5
pause 5
low 5
tune B.1, 3, 001100,($D0,$04,$05,$45,$44,$02,$40,$42,$45,$42)
high 5
pause 5
low 5
tune B.1, 3, 001100,($C2,$07,$04,$44,$42,$C0,$40,$07,$0C,$C5,$CC)
'Strollin1b
tune B.1, 3, 001100,($60,$62,$65)
high 5
pause 5
low 5
tune B.1, 3, 001100,($62,$29,$69,$29)
high 5
pause 5
low 5
tune B.1, 3, 001100,($27,$E7,$60)
high 5
pause 5
low 5
tune B.1, 3, 001100,($62,$65,$62,$27)
high 5
pause 5
low 5
tune B.1, 3, 001100,($67,$67,$27)
high 5
pause 5
low 5
tune B.1, 3, 001100,($25,$65,$64,$22)
high 5
pause 5
low 5
tune B.1, 3, 001100,($60,$62,$65)
high 5
pause 5
low 5
tune B.1, 3, 001100,($62,$E5,$27,$24)
high 5
pause 5
low 5
tune B.1, 3, 001100,($64,$62,$E0)
high 5
pause 5
low 5
tune B.1, 3, 001100,($20,$E7,$A5,$60)
high 5
pause 5
low 5
tune B.1, 3, 001100,($62,$65,$62)
high 5
pause 5
low 5
tune B.1, 3, 001100,($29,$69,$69,$29)
high 5
pause 5
low 5
tune B.1, 3, 001100,($27,$E7,$60)
high 5
pause 5
low 5
tune B.1, 3, 001100,($62,$65,$62,$C0)
high 5
pause 5
low 5
tune B.1, 3, 001100,($24,$25,$65)
high 5
pause 5
low 5
tune B.1, 3, 001100,($64,$22,$60,$62)
high 5
pause 5
low 5
tune B.1, 3, 001100,($65,$62,$E2)
high 5
pause 5
low 5
tune B.1, 3, 001100,($27,$24,$64,$62)
high 5
pause 5
low 5
tune B.1, 3, 001100,($E0,$60,$27,$2C,$E5,$EC)
'Strollin1
tune B.1, 2, 001100,($40,$42,$45,$42,$09,$49,$09,$07,$C7,$40,$42,$45,$42,$07,$47,$47,$07,$05,$45,$44,$02,$40,$42,$45,$42,$C5,$07,$04,$44,$42,$C0,$00,$C7,$85,$40,$42,$45,$42,$09,$49,$49,$09,$07,$C7,$40,$42,$45,$42,$D0,$04,$05,$45,$44,$02,$40,$42,$45,$42,$C2,$07,$04,$44,$42,$C0,$40,$07,$0C,$C5,$CC)
'Strollin1b
tune B.1, 2, 001100,($60,$62,$65,$62,$29,$69,$29,$27,$E7,$60,$62,$65,$62,$27,$67,$67,$27,$25,$65,$64,$22,$60,$62,$65,$62,$E5,$27,$24,$64,$62,$E0,$20,$E7,$A5,$60,$62,$65,$62,$29,$69,$69,$29,$27,$E7,$60,$62,$65,$62,$C0,$24,$25,$65,$64,$22,$60,$62,$65,$62,$E2,$27,$24,$64,$62,$E0,$60,$27,$2C,$E5,$EC)
goto strollin

strollin:
'Strollin1
tune B.1, 1, 001100,($40,$42,$45,$42,$09,$49,$09,$07,$C7,$40,$42,$45,$42,$07,$47,$47,$07,$05,$45,$44,$02,$40,$42,$45,$42,$C5,$07,$04,$44,$42,$C0,$00,$C7,$85,$40,$42,$45,$42,$09,$49,$49,$09,$07,$C7,$40,$42,$45,$42,$D0,$04,$05,$45,$44,$02,$40,$42,$45,$42,$C2,$07,$04,$44,$42,$C0,$40,$07,$0C,$C5,$CC)
'Strollin1b
tune B.1, 1, 001100,($60,$62,$65,$62,$29,$69,$29,$27,$E7,$60,$62,$65,$62,$27,$67,$67,$27,$25,$65,$64,$22,$60,$62,$65,$62,$E5,$27,$24,$64,$62,$E0,$20,$E7,$A5,$60,$62,$65,$62,$29,$69,$69,$29,$27,$E7,$60,$62,$65,$62,$C0,$24,$25,$65,$64,$22,$60,$62,$65,$62,$E2,$27,$24,$64,$62,$E0,$60,$27,$2C,$E5,$EC)
goto strollin

Hacking a Toy pt. 3

Tonight, we continued programming and circuit-bending with our hacked toys.

I was able to find many shortcuts hidden in the Picaxe manual, namely related to functions for sound generation. This eliminates all need for guesswork in creating specific musical tones, and should cut my programming time considerably in addition to providing more musical options for the hacked toy's final software.

Wednesday, January 25, 2012

Picaxe Sound Function

Through experimentation and a trained ear, I found that the Picaxe Basic function "sound" provides audible notes in a range of chords starting at a frequency of 40 and increasing by one full step in increments of 6, plus or minus a value of 2--one full octave higher than tone 40 is at 84.


Equipped with this knowledge, I can begin programming basic sheet music into the picaxe's memory.




**UPDATE** 3:56pm


Using a digital tuner I was able to confirm that tone 40 and tone 84 are in fact the musical note "A"

Hacking a Toy pt. 2 -- Interfacing a Toy to User Command

A continuation of exploring possibilities for bending the original logic of an electronic-based toy.


*Original logic-board removed

A shot of the extension wires I soldered into place to take control of the sensors and outputs of the toy, keeping original color and polarity.


Soldering extension wires to the speaker proved a greater task than the other four, simply because of the low quality of the wafer attached to the base of the speaker which would flake and adhere to the solder, providing for a challenging joint.


Heat shrink was used to group wires, making it easier to visually follow their paths of execution to product (color) without opening the toy, hopefully simplifying process and  cutting down on time spent troubleshooting.


A demonstration of direct control over the motor function of the toy--pressing the switch on the breadboard would supply 5V and cause the wheels to spin on command.
In a separate demonstration, the existing program (compiled over the weekend) would provide a range of  incremental sound frequencies when the microcontroller was interfaced with the speaker.

Friday, January 20, 2012

Circuit Bending and "Hacking a Toy"

Self-explanatory experiments in bypassing the original logic of an electronic-based toy to implement our own.


Original Toy

When the power supply circuit was closed, the toy could be activated by shaking it, due to a small ball switch (orange wires) energizing the logic board to the "awake" state. The toy would emit sound from a speaker (yellow wires) and drive the rear wheel axle motor (red wires). Also included were a pressure switch attached to the front axle (purple wires), indicating that the toy was placed on the ground, and a bar switch 
(blue wires), which was included but did not appear to be attached to any mechanical interface--most likely, it  was a leftover process from another feature that the manufacturer had intended.


Logic-board exposed.

Interestingly, the rear axle of the toy is not a single-shaft direct-drive gearset. It has an "open" differential, leading to greater possibilities for hacking by locking up one wheel to make the toy turn while the motor is being driven forward or backward.

Thursday, January 19, 2012

Logic Probe and Picaxe Interfacing/Programming

We finished soldering on our logic probes to be used for identifying circuit logic and stray voltages.



Once the probes were soldered, interconnected wells on the wafer had to be "cut" to match the desired paths for current.


The next stage of our projects would make heavy use of a standard serial COM port to interface our Picaxe microcontrollers with a desktop computer for programming, so one was fashioned.



A detour in exercising transistor control.


The wiring diagram for interfacing a Picaxe 08M2 with a desktop PC serial port for programming in 
Picaxe Programmer.



A successfully executed "flasher" program written in basic and downloaded to the 08M2, pulsing a red LED.

Wednesday, January 18, 2012

VEX Bot and Logic Probe

Taking a break from previous activities, we built basic VEX "square bots" as a precursory toward concepts of mechanical structure, build technique and creativity.


When the robot was finished
(over the weekend, at home, as class-time is now desperately needed to catch up on other activities....
and it's robots....which is like, the ultimate hobby),
it was handed over to a team of programmers who, after some technical difficulties, installed matching firmware and a basic VEX robot drive program to allow manual operation of the robot via a wireless controller. Once the robot was successfully paired with the operator controller and demonstrated to be in proper working order, it was set aside and we began building our logic probes.


After demonstrating an understanding of basic transistor theory and uses in simple circuits, we set to the task of prototyping a simple Hi-Low voltage logic probe on breadboards before be signed off to finalize the design on a small circuitboard. Sans the PWR and GND cables, the above picture represents all the hardware necessary and soldered in place.