Quantcast
Channel: Wardy's Projects
Viewing all 70 articles
Browse latest View live

Laser Modulation

$
0
0
More fun with lasers!

I discovered (why didn't I realise this the other day?) that a 5mm LED fits snugly into the muzzle of this laser module, so I can take very accurate readings of the voltage across the LED now without the stupid brass tube getting in the way.

Hooking up my Fisher Price oscilloscope to the LED sensor gives me the following waveform...


I was driving this laser by providing a 5kHz 50% duty cycle PWM signal using a Parallax Propeller and using a 2N3904 transistor (with no base resistor!) in order to supply enough current to the laser module.

This scope trace is basically a direct reading of the light output which is then captured by the silicon die on the LED sensor.  The scope probes are crap, the scope is crap so this isn't a good measurement really.

However the trace was very solid so I'm happy that I can use this setup to test for improvements to the modulation pattern of this laser.  This trace would suggest that the rise time is quite favourable - I'd estimate about 25microseconds.  The flat bit is maybe 65uS and the falling slope takes the remaining 110uS.

Complications:
1. I can't get the laser module out of it's metal housing - I suspect it's epoxied in there to deter foolish tinkerers like myself meddling with things they should not wot of.

2. There looks to be a voltage regulation circuit in there (unsurprisingly) that will be fighting against my attempts to drive the laser by applying PWM to the battery terminals as I have been doing so far.  I've noticed that with increasing PWM frequencies, the resultant light output from the laser becomes smoothed out over the whole PWM amplitude so that ultimately at infinite PQM frequency, the laser would simply emit a steady beam at around 50% peak intensity (that's a naíve description of course, life's not that simple in practice).

Conjecture:
1. If I can get the casing off this laser then perhaps I can bypass the voltage regulator circuitry and drive the diode with a circuit of my own making that will allow me to run the PWM faster and with sharper rise and fall times.

If I try to use this setup on my UV laser plotter then the resultant images would look a bit blurred.  In fact, due to that slow fall time it would probably look like a motion blur - as if the image was moving upwards!  No good at all.

The plan is to get the rise and fall times to at least be equal - which would prevent any blurring in the final images.  If I can make the whole waveform modulate a lot faster as well then that would be great because I could regulate the exposures more accurately and produce a sharper and more detailed image.

Now I have to find a way to get this case open.

Up in Flames

$
0
0
It's Friday the 17th!!!! (cue lightning and thunder).



Today I fatally destroyed 2 electronic components and released a non fatal amount of magic smoke from a third.

The walking-wounded survivor of this silicon apocalypse was the soft-start / voltage step-up circuit.  Connecting a 9v battery directly to a circuit expecting 3v will do that.  A small wisp of white smoke made a bid for freedom from a diode but on later inspection it seems that the circuit is still in spec.  More on this later*.

The first of the evening's honoured dead is the UV laser diode from one of the laser pointers I procured from the ebay the other day.  I had rent asunder the metal housing of the unit to extract the interesting bits within and had started to contemplate the workings of the laser drive circuitry.  This involved desoldering the laser diode and placing it to one side.  Later on when reassembling the unit the bloody thing wouldn't work any more so I reckon I've probably knackered it.  Arse.

Lastly, but certainly most annoyingly and expensively is the Schmalzhaus EasyDriver (4.4) that I stupidly jettisoned into the afterlife by unplugging a motor from while the board was live.  I saw the soul of the board escape in a tiny blue flash between the plug and socket.  A heartfelt expletive was softly but emphatically uttered in my lab.  Rest in peace, you served me well.

Sometimes the smoke wants to get out and there's not a lot we can do to stop it, other times it's all down to me being a dope and not really thinking about what I'm doing.

I've got another couple of EasyDrivers on order.  Ho hum.  They are very good value for money though, so it's not a huge financial loss.  The pride took a bit of a knock, but how else do we learn, eh?



It's all good fun.



-----------------------
* Back to that step-up circuit though, I was surprised to learn that my UV laser pointers (which feed on a pair of AAA cells) actually require 35Volts(!) for the diode to get into it's lasing region.  Here's a pic of the step-up circuit, which was literally torn unceremoniously from it's aluminium tube by ripping the metal housing with pliers...


Papilio One 500K

$
0
0
Arrived today...


Shown here next to another popular development board that doesn't need naming.

I'll do a review of this thing once I've had chance to play with it.

First impressions - Papilio One 500K FPGA Development Board

$
0
0
I've had a few days to play with my FPGA kit now since it arrived last week.

I'm going to get the moaning over with first, don't worry, it gets better later on, stick around...

The Papilio website freely admits that this product is inspired by the Arduino project.  Well that's nice I guess.  It doesn't help though.  The Papilio website, nice as it is, is just as bad as the Arduino one.

Another thing the Papilio shares with the Arduino is the appalling manufacture quality.

Upon arrival, my Papilio showed poor quality soldering on all the through-hole parts (the jumper posts for voltage selection).  I had to desolder and re-do all the through hole joints before I was happy that the thing would probably work before I took the power plug anywhere near it.  If I pay £60 for something that is nothing more than a circuit board with a few simple parts on I want it FINISHED before I get it.

That's not the worst though.  Three of the jumpers had NO solder on one side of the gap.  Not even a bad joint, just no solder at all.  Unbelievable.

My supplier is just as much to blame as the manufacturer, but I won't go into that now.

Anyway, rant over.  I was ticked off but still prepared to finish the product for them on my bench before commencing with the festivities of hacking some cute little hello-world circuit together.

Step 1 is to solder on some female header strips to the IO ports.  I don't mind this at all, my iron was already hot anyway right?

Step 2 is to plug it in and watch the power LED come on... check!  Yup, it works.

Step 3 is to wander around the website looking for a hint regarding what software I need to actually flash code onto this thing.  That was easy enough, it's easily found from the main page.

Step 4 is to wonder how to write code for this thing...

Hmm....


They don't go out of their way to make that easy.  I couldn't find any recommendations regarding what dev tools to use, at least not on the main site.  I had to download a bunch of tutorials first and then go with the average toolset that everyone seems to use.  This turned out to be the "Xilinx Design Tools".  Great, now all I have to do is download this installer and off we go!

Another minor rant (sorry)...

The analogy between Papilio and Arduino starts to dissolve when you realise that this Xilinx dev kit (apparently the most accessible one by all accounts), is almost 18 gigabytes in magnitude.

18,000,000,000 bytes.  Seriously.

After regaining sensation in the left side of my body I bit the bullet and downloaded it.  Then I went to bed.  Later that week I installed the dev kit, and went to bed again, what with it being too late at night to actually do any useful hacking.

Only one further annoyance assailed me - the software doesn't play well with Windows 7.  You have to "Run as administrator" if you want to do something exotic such as save a file to your hard drive (this is 2012 after all).

My gluttony for punishment was then sated when everything from that point onward began to run smoothly.

Breadboarding up a few switches and LEDs allowed me to throw some code on this FPGA board and coax life out of it!  Then I soldered up a proper perfboard circuit with male headers to allow more long-term prototyping...


Great.  Now I'm in business.

In a follow-up post I'll share some code that I used with this IO "wing" board that shows a 3-bit full adder configuration on the FPGA.

UV Imager - progress made!

$
0
0


Finally got around to making a start on the power-on calibration for the UV Imager.

The Flickr page for this video has a brief footnote about the workings of it, but the vid is fairly self explanatory.

The control circuitry for this is basically a Parallax Propeller microcontroller (which is incredibly awesome in itself) with a bunch of switches, an LCD panel and a pair of EasyDriver (v44) modules attached.

Once I've fine-tuned this start-up sequence I can begin to write the PC software that sends graphical commands to the Propeller that describe the bitmap image that is to be imprinted on the UV paper.

VGA - FPGA - VHDL and other assorted acronyms!

$
0
0
Not since I started playing with the Parallax Propeller microcontroller last year have I found such a goldmine of hacking potential as with FPGAs.

My latest challenge has been to display a clear and coherent signal on my TV set using VGA signalling.  Up to now I have had varying levels of success in persuading a Propeller chip to display exactly what I wanted on an VGA screen.  That's not a criticism of the Propeller (heavens forbid!) but more of my own PASM programming.  I found that trying to coax the Prop into drawing pretty pictures was an exercise in pain and capitulation.  Painful in that you have to jump through many obscure hoops and in the end you end up just using a code sample off the internet written by Our Corporeal Lord, the Highly Venerable Sir Chip Gracey, Esquire.

With FPGAs, there's none of that diabolical faffing around.  You can just use some really clear (compared to assembly language) and human-readable code to describe the signals you're trying to generate and that gets encoded into a stream of configuration bits which then is fed into the FPGA device and suddenly you've got a nice neat signal on your VGA screen.  The ease with which this amazing feat can be performed is very surprising.  All it takes is a few days of keen study in the art of VHDL design (there's plenty of entry level info on the internet, naturally) and then some quick (read: prolonged and frustrated*) research into how VGA signalling works and you've got all the tools you need to write the code to make an FPGA generate video signals.

Here's my first attempt at a half-decently written VGA code module in VHDL...

VGA.vhd source code

The test pattern is merely a 800x600 pixel display (2 bits per R,G,B channel) showing a full white background and a 2x2 red dot in the centre of the image.  My LCD TV shows this very stably although there is some fuzziness detectable around the red dot, probably due to some timing issues or perhaps that 800x600 is very much non-optimal for my TV set.  I'll have a play around with other resolutions until I find a really sharp picture and then develop this code further.



----

*A couple of links that VGA-interested people might want to look at are: http://tinyvga.com/vga-timing/800x600@60Hz and http://www.johnloomis.org/altera/DE2/vga.html but take those with a pinch of salt.  My VGA generator wouldn't work unless I used rising edge sync pulses, and it seems that sources of info on that will vary.

VGA - Conquered!

$
0
0
New and improved VGA.vhd source code (VHDL) 

After much headscratching and frustration I engaged the little grey cells and contemplated the nature of the signal I was trying to generate.

VGA signalling is very simple on the face of it but the frequencies involved are often a lot higher than things like jump wires and breadboards can sensible cope with.  Most of my projects so far have used relatively sedate clock rates (sub-10MHz digital stuff).

My FPGA's main clock signal  is set up to be a simple 40 Megahertz 50% duty cycle signal, derived from the FPGA dev board's on-board crystal oscillator.  That's all done internally in the FPGA chip of course but the output signals of the chip have to travel (in my experiment circuit) through some cheap pin headers, over a few inches of jump wire into some more headers inside the Propeller Dev board (that I'm using simply because it has a VGA socket on it!) and out to the VGA cable into the TV.

Little wonder then that I had so much trouble getting a coherent picture to show.  In the end I could get a signal I'm happy with my digressing from the standard VGA timings by a tiny amount (nudging the horizontal sync to be two pixels earlier and two pixels longer).  This seems to overcome the problems in the wiring (jitter and inductance I think).  So now my FPGA code can generate a lovely, sharp(ish) 800x600 VGA signal that I'm quite pleased with, now that all 4 sides are correctly registered on the screen.

Multiple TVs seem to agree that it's a reasonable signal quality so I'm confident that the bodge is required because of the breadboarded state of the system.  Once I get this thing properly built (if that ever happens) then I should be able to revert to the standard VGA signalling timings.


Meetups and teardowns

$
0
0
Tuesday night saw Derby Makers' inaugural Annual General Meeting take place at the historic Derby Silk Mill.

Lots of positive discussion was had and some exciting new developments regarding both the Museum and related organisations were talked about.  Some forthcoming events were also outlined and gave rise to very enthusiastic brainstorming about impending project ideas.

One such idea was sketched out frantically around the AGM table (accompanied by lots of illustrative arm waving and silly gesturing).  I am sworn to secrecy at the moment but suffice it to say that the remainder of this blog post is a tiny hint as to what is to follow...




The secret project requires an object to receive a simple set of on/off signals from a short distance away.
We decided that we wanted to keep things as simple as possible so I initially thought about using an old TV remote control as a means of sending pulses of light to the remote device.  The several TV remotes that I tested (on my logic analyser) all produced a bunch of coded binary signals and would require a fair bit of programming to decypher.  Nope, this hack would be more awesome if it were thrown together with minimal effort on things like that.

Radio control then presented itself as a possibility.  Nothing fancy, of course, preferably something very small ...Something like this...


This little gem was gathering dust in the lab and seemed perfect for the task at hand.

Basically it's a tiny RC car with 3-way steering and forward-stop-reverse motion.  The mouse shaped thing is merely the shell that goes on top of the car to make it "fun to play with".  In reality the novelty wears off in about 4 seconds, when you realise just how cheaply made it is.

What it does have is some nice binary signalling to hack into!

Close ups...




The above pic is a close up of the receiver unit that lives in the car.  The wires on the right side are (from top to bottom):

Black wire- battery negative
Magnet wire - steering coil (LEFT)
Magnet wire - steering coil (RIGHT)
Blue wire - motor power A
Red wire - motor power B
Pair of magnet wires - common GND for steering coils
Red wire - battery positive

The on-board battery is a tiny little 1.2c nicad rechargeable cell.  This is charged by docking the car itself onto the controller handset by means of a pair of snap-on clips.  Charging simply draws current from the pair of AAA batteries in the handset, and takes about a minute or so.

To be honest the quality of the product is higher than I had expected given the asking price of less than £10 when it was new about 6 years ago.  The PCB is not bad, it's a 2 layer with PTH and has very few vias, indicating a fairly efficient board layout.  The soldering is appalling, as you'd expect.

The plan is to connect the outputs of this simple radio receiver to a ATTiny85's ADC pin (via a resistor network) in order to provide the chip with user input so the chip can then ..... oh wait, that's a secret :)

I'm planning to put a bit of cleverness into the ATTiny's firmware to allow some "cheat-code" features... if you press the controller buttons in the right order then interesting things happen in the system!

The various bits of circuitry I've gathered together for this build (including batteries) weigh about 80 grams.  Which is about as heavy as I want the electronics to get.  I won't tell you why :)

I will build a little circuit that will allow this 1.2 volt circuit to be run from a main supply of probably 3.3 volts, which makes all sorts of things possible.

Watch this space!

Enigma Machine Project - Progress!

$
0
0
After making some enquiries at the Derby Makers discussion group a while back, Martin Raynsford got in touch and kindly offered his assistance in fabricating some parts for my Enigma machine project.

Martin has a lot of experience with using laser cutters, which is the topic for his blog.

So I threw together some quick CAD drawings for him and today the prototypes arrived!

The parts are 4 pieces of perspex of sandwiched together and held in place with a pair of M3 screws.  2 different patterns were used, the centre two pieces have a small hole in the middle to house a ball bearing that allows the brass shaft to run through it centrally.  The outer two pieces have a large hole and allow clearance for the rotors and their fixings.  The whole thing is 16mm thick and looks absolutely awesome.

Here's a few pictures...

SAM_1263

A) The perspex sandwich alongside one of the rotors.
B) Edge-on view of the perspex parts with the electrically conductive parts fitted.
C) Perspex and rotor in approximate alignment.
D) Close up of holes and rotor conductors.
E) Illuminating the perspex with 8 high intensity red LEDs.  Looks better in real life actually.

I'm very pleased with this prototype - it's even better than I had hoped for and looks rather professional I think.

Huge thanks to Martin for making this design far better than I could have managed on my own - everyone should go and have a look at his recently completed "365 laser-cut designs" project on his site (see the link at the top of this post).  You can even buy some of his designs from him directly!

Awesome.

More Perspex!

$
0
0
Today's mailbag provided me with some new parts for the Enigma Machine!

Martin Raynsford has cut some more parts for me after a significant re-think of the Enigma design.  Instead of the "tombstone" shaped parts from last time, I've changed the design to use a set of 16 hexagonal parts all mounted on a set of three steel threaded rods.

The assembly is a bit hard to describe so I'll just use some pictures instead.

For the time being, I'm keeping the perspex's protective film in place so the final product has a fighting chance of looking smart and presentable.



SAM_1270

Nylon machine screws are the future by the way.  Go and buy some and see for yourself.

Propeller: Synchronising two or more Cogs

$
0
0
Purely out of curiosity I decided to do an experiment into the nature of one Propeller Cog's temporal relationship with another Cog.  Is the instruction executions of two (or more) Cogs constant, or can the phase between them be changed?

One thing we can find out easily from the datasheet and manual for the Propeller is "hub instructions take from 8 to 23 cycles to complete".  Interesting if you think hard enough about it.  If your code uses many Cogs and calls hub instructions many times per Cog, then over time it is quite possible that events that you need to remain synchronised between Cogs can drift out of the idea pattern that you intended, due to the way your program branches or loops.  Certain applications might require a means to re-synchronise two or more Cogs to adhere to some external specification that you wish to adhere to.

While the Propeller's instruction execution timing is certainly deterministic (it will always behave in exactly the same manner each time a program is run), it is not necessarily intuitive or easy for the programmer to predict, once a program exceeds a certain complexity.  Sometimes you just have to run the program and see what happens.

The experiment I wanted to conduct was intended to determine whether a programmer can deliberately influence the phase difference between two or more Cogs in a Propeller microcontroller.  There are many reasons to want to do this, including high-speed signalling, analog-digital conversion, audio generation and so on...

The Experiment...

Aim: to start up two Cogs using Spin code (by calling the cognew function twice) and then influence the phase (for want of a better word) difference between execution cycles on the two Cogs.

In other words, when two Cogs are made to toggle a pin each, is it possible to force the Cogs to toggle at the same time?  Equally, is it possible to make them toggle the pins out of synchrony with each-other?

I needed a simple way to test the theorem.  If I have one Cog running a simple tight-loop that toggles a pin each iteration, then I should be able to run another Cog that does basically the same thing but alter it slightly so that before starting the loop add a delay until a time when the second Cog is "in phase" with the first Cog.  

If it works then both Cogs should end up toggling the pins on the same global clock cycle.

I wrote the following code to try this out...



CON
_clkmode = RCFAST

PUB Main

cognew(@METRONOME, 1)
cognew(@MODULATED, 0)

DAT

'FIRST COG's task...

org 0
METRONOME
mov dira, metronome_pin
mov outa, #0
mov counta, #256

:a xor outa, metronome_pin
djnz counta, #:a

waitpeq $, #0

metronome_pin long |< 0
counta res 1

fit





'SECOND COG's task...


org 0
MODULATED
or dira, modulated_pin
mov outa, #0
mov countb, #64 'number of iterations before the delay
mov countc, #64 'number of iterations after the delay

:b xor outa, modulated_pin 'tight loop toggling a pin
djnz countb, #:b

' << cleverly chosen time delay here >>
mov time, cnt
add time, #17 'minimum value is 9. Choose this carefully in order to synchronise your cogs
waitcnt time, 0
'time delay code ends

'NOW the two cogs should be IN PHASE! :)

:c xor outa, modulated_pin 'tight loop toggling a pin
djnz countc, #:c

waitpeq $, #0 'sleep forever

modulated_pin long |< 1
time res 1
countb res 1
countc res 1

fit




This code isn't very complex, it should run on a bare chip and uses the internal timer.  In fact using the internal timer is recommended because it the slow clock rate makes it easier to measure the exact timings of the pin states using a logic analyser!  I used my marvellous "Saleae Logic" (go buy one right now, seriously).

The following screenshots show the output of the two Propeller IO pins, but first a little explanation of the code is in order, since Propeller Assembly language (PASM) might be an alien language for some readers...

I have created a pair of Cog tasks named METRONOME and MODULATED.  Cog 1 begins running the METRONOME code first, followed shortly afterwards by Cog 0 being restarted and running the MODULATED task.

Each Cog task toggles a different pin on the Propeller.  METRONOME starts first and toggles pin P0.  MODULATED starts a moment later and toggles pin P1 as soon as it starts, then takes a short delay where it stops toggling.  After the delay it resumes toggling again but this time it's instruction execution "phase" has been adjusted to be synchronised with the METRONOME task.

Because Spin is an interpreted language, it is not obvious how many clock cycles elapse between METRONOME starting and MODULATED starting.  We know that both cogs will eventually be running simultaneously but there will be some relatively large time offset between them.

Take a look at the Logic analyser's recordings of P0 and P1 over time...



What we see here is that during the first loop ("b") in the MODULATED task, the pin toggling is out of phase with the METRONOME task on the other Cog.  For my purposes I wanted to be able to rectify this so that future pin toggling happens in phase with the METRONOME task.

We have a number of facts at our disposal now...
1) Both Cogs are running at the same clock frequency.
2) Propeller Cogs execute XOR instructions and non-jumping DJNZ instructions in 4 clock cycles each.  So each iteration of the toggling loops take 8 clock cycles each - this is a fixed value.
3) Hub instructions can elapse an amount of time that is an odd number of clock cycles.

Given these facts we can logically influence the phase difference between the instruction execution time on two separate cogs by as little as 1 clock cycles (remember that most instructions are 4 clocks in duration).

Turns out that the WAITCNT instruction gives you single-clock-cycle timing resolution, although this isn't explicitly stated in the datasheet or the manual for the Propeller P8X32A chip, as far as I am aware.

The Solution...


mov     time, cnt
add time, #17
waitcnt time, 0


The "#17" seen here is the offset (in clock cycles) into the future to make the Cog wait until.  Seventeen is arbitrary for this experiment.  Using numbers smaller than 9 will cause the waitcnt mechanism to wrap around it's 32 bits worth of timing counter and this would cause many many hours of fruitless inactivity, so don't use numbers less than 9.

For this super-simple experiment 17 is good enough to sync up these two very tight loops.  If your loops take longer then you'll need to select a delay that allows your slower loop to wait until the faster loop to get back into a state that can be "joined" by the slow loop.  The delay could be up into the thousands or millions if you're using very long loops or using high clock speeds with external crystals and high PLL multipliers.


The Conclusion...

It is possible to change the phase relationship between two or more Cogs that are both running assembler code.  This is potentially very handy if you're having some weird timing issues on your multi-Cog applications.  If in doubt, get the logic analyser out!

This isn't a particularly advanced topic though, I just went into this amount of detail because it's quite good fun to look deeply into the Propeller anyway, and who knows, it might be useful to someone somewhere.

If this is useful to you then please leave a comment and let me know.

Good luck :)




True RNG?

$
0
0
I was inspired the other day by a post on Hackaday.com...

http://hackaday.com/2013/01/17/hackaday-links-january-17th-2013/

I had all the bits lying around so I thought I'd have a go as well.  I have wanted to build a high quality entropy source to put on my network for a long time now (actually it was the main reason I took up electronics as a hobby a couple of years ago :)

I'm using a servo with an egg-timer hot-glued to it - swingint it through 180 degrees is really easy and fast and requires no bearings.  The low-precision nature of the cheap servo will only help the randomness over time.

The laser is a £5 1mW purple laser pointer I scored off Ebay last year (it's the same one I was using to power an ATTiny5 microcontroller: http://wardyprojects.blogspot.co.uk/2012/08/using-laser-to-power-attiny5.html).

I'm using the laser to illuminate the white sand grains as they fall through the egg timer's lower bulb.  The sensor is mounted on the servo housing and is not in the direct "firing line" of the laser - this is to allow a much wider range of light levels hitting the sensor.

The sensor is an LED connected directly between GND and the base of a 2n3904 NPN transistor to gain up the signal a little before it's sampled by the arduino's ADC pin.

It seems to work very well indeed, values between 200 and 1024 (the ADC's maximum) are frequently attained.  The oscilloscope suggests a very chaotic signal but will the data generated by this simplistic system actually be of any use as a viable entropy source?

This remains to be seen, I'll log a few hundred megabytes of data (assuming the servo doesn't wear out) and use the "Diehard" randomness test kit to measure just how good this system is.

It's not secure in it's present state of course, all you'd have to do to force it to output 1111111111111111...... forever would be to leave it in the sunshine!  I'll have to build a light-tight enclosure for it before I use it properly. :)

Have a look at the video and then skip on over to PART 2...



True RNG (part 2)

$
0
0
I've added an Ethernet Shield to the Arduino that controls my egg-timer based RNG.

It's logging about 52kb per second (420000 bits per second or thereabouts) over a UDP port to my clunky old Acer netbook running CrunchBang linux (which is an awesome OS by the way).

I used "netcat" (a standard linux tool) to dump the raw binary UDP packets to a file on the linux box's hard disk for later analysis.  I tested a 300kb file of random garbage against a few of the DieHarder tests.

It's passed the small number of tests I've subjected it to so far.

I'll flog it a bit more and see if I can get the high score higher than 5%.




But a pass is a pass, right?

Fun :)

Installing a Propeller Toolchain under Linux

$
0
0
Found a good article on installing linux tools for develping code for Parallax Propeller microcontrollers...

http://gpio.kaltpost.de/?page_id=1378

Contains instructions for BST and installing a great spin code syntax highlighter for VIM.


Useful links for Propeller Programmers

$
0
0
(1) Parallax's Original Spin interpreter code...
http://forums.parallax.com/showthread.php/101336...

(2) The Propeller's "Three Bit Protocol" for code downloads
http://forums.parallax.com/showthread.php/97913-The-3-Bit-Protocol

(3) Minimal PASM bootstrap code...
http://forums.parallax.com/showthread.php/86056....

(4) More general info on cool Prop stuff and a bit more detail about the 3bit protocol...
http://propeller.wikispaces.com/Download+Protocol

(5) A rather eclectic PDF of various Propeller based topics including some fascinating topics.  I believe the content was generated by the nice folks at http://propeller.wikispaces.com/ Here's the PDF.

(6) The entire Propeller Boot ROM source code (Courtesy of Sir Chip Gracey)
http://forums.parallax.com/showthread.php/101483...



//----------------------------------------//

//An exerpt from that minimal bootstrapping code forum thread...

Minimal Spin bootstrap code for assembly language launch
--------------------------------------------------------

$0000: HZ HZ HZ HZCR CS 10 00 LL LL 18 00 18 00 10 00
$0010: FF FF F9 FF FF FF F9 FF 35 37 04 35 2C -- -- --

$0020: your assembly code starts here - loaded into COG #0


elaboration:

$0000: HZ HZ HZ HZ - internal clock frequency in Hz (long)
$0004: CR········· - value to be written to clock register (byte)
$0005: CS········· - checksum so that all RAM bytes will sum to 0 (modulus 256)
$0006: 10 00······ - 'pbase' (word) must be $0010
$0008: LL LL······ - 'vbase' (word) number of longs loaded times 4
$000A: 18 00······ - 'dbase' (word) above where $FFF9FFFF's get placed
$000C: 18 00······ - 'pcurr' (word) points to Spin code
$000E: 10 00······ - 'dcurr' (word) points to local stack

$0010: FF FF F9 FF - below local stack, must be $FFF9FFFF
$0014: FF FF F9 FF - below local stack, must be $FFF9FFFF
$0018: 35········· - push #0·· (long written to $0010)
$0019: 37 04······ - push #$20 (long written to $0014)
$001B: 35········· - push #0·· (long written to $0018)
$001C: 2C········· - COGINIT(0, $20, 0) - load asm code from $20+ into same COG #0
$001D: -- -- --··· - filler

$0020: XX XX XX XX - 1st long of asm program to be loaded into COG #0
$0024: XX XX XX XX - 2nd long of asm program to be loaded into COG #0
$0028:············ - rest of data

Latest Project - RasPi as a portable Propeller development kit.

$
0
0
I decided to treat myself and get a Raspberry Pi computer, it arrived yesterday and literally within 5 minutes of opening the box I had compiled a hello world C program and proved that I can use a standard USB FTDI adapter to talk to a Propeller chip -- with zero configuration necessary.

That impresses me greatly.  I hate the fact that most popular new development platforms require you to download umpteen dependencies and some random GUI or IDE libraries that seem entirely superfluous (QT, GTK, Eclipse etc etc etc.............. ad nauseum).  Nope, none of that crap with the RasPi.  It just did what I wanted right out of the box.  Brilliant stuff.

My plan is to replace the apparently no-longer-supported Linux tools for programming the Propeller chip and it's EEPROM.  I have started writing my own code downloader already and it's probably 50% complete at the moment.  I may write an assembler later on if there's some interest from the Propeller community.

The downloader program (entitled "pushprop" for the time being, see the banner link at the very top of this blog) will compile and run natively and without any kind of dependencies whatsoever on a Raspberr Pi computer.  I despise dependencies and refuse to inflict them on other people :)  It's all written in standard C and should "just work".  It will be an Open Source project and it the software will be free.  I will also make the hardware part (the custom PCB I'll have to design) Open Source, and anyone will be ably to build their own if they like.


pushprop Project Progress

$
0
0
A quick update to the pushprop application project (see the page heading at the top of this blog page for more info)...

----------------

Happy to report good progress with this project!  My current state of completion is thus (at time of writing) :


  • Supports all four main chip-programming modes (shutdown only, load RAM and run, load EEPROM and shutdown and load EEPROM and run).
  • Supports automatic checksum recalculation during the chip RAM / EEPROM download sequence.  This is required for some of the other exotic features I'm adding such as serial number embedding.
  • Supports serial number embedding.  Insert a user-specifiable 32 bit serial number into a user-specifiable long address in the EEPROM image (just before it's inserted into the Propeller).  This requires the auto-checksum feature to be enabled else it won't pass the Propeller's checksum validity test.  I've tested this by writing a short PASM program that writes the memory area back to the PC over serial, works nicely :)
It's still not stable enough for release unfortunately.  I'll have to improve the primitive user argument handling code before it goes out into the world otherwise people will complain that it's a bit fussy.

One feature that I'm eager to implement is the ability to have the Propeller chip read it's own EEPROM and send the data back to the PD over the serial link all in one command.  This will require me to embed a small Propeller program within the actual Linux program so I can send that temporarily to the Propeller's RAM and have it run from there.  That will be challenging but fun.


The code download protocol isn't difficult to understand at all, once you know that you have possession of the facts and that those facts are verifiable when tested.  That was the hard part and I think I've got there in the end.  Surprisingly, there is no official documentation for the Propeller's code download protocol!  The best I could find was a somewhat sparse and ambiguous set of rough notes from Chip Gracey (himself!) on the Parallax forums.

Also a collection of equally troublesome documents were tracked down in due course and added to the mix in order to iron out some of the confusion.  I will write up my own findings and publish what I believe to be an accurate description of the Propeller's download protocol (colloquially known as "3BP - the Three Bit Protocol").

In any case the code will be open source so it'll be there for all to see :)

Electron Bothering - I2C

$
0
0
I2C is a neat "little" protocol.  The inverted commas are an indication of the magnitude of the technical documents that define this protocol.  They are large and for the most part actually quite readable and comprehensible.  I'll let the interested reader refer to the wikipedia page on this topic which is highly recommended as a jumping-off point for further research.

Anyway, my recent delvings into the interesting field of I2C (pronounced "eye squared see") were necessary because of my latest hacking project "pushprop".

Elsewhere on my blog I've posted a more detailed description of what pushprop is, but suffice it to say for this posting that pushprop is basically the software half of a much more significant project - a project that has no name as of yet.

The hardware half of this project is to be a "shield" PCB for the increasingly ubiquitous Raspberry Pi computer system.

Without wanting to reveal details which might end up changing at a later date, I'll only say that the shield PCB will feature at least 1 P8X32A microcontroller, but I'm aiming for "several" of them.  I'm also hoping to have a configurable distributed system clock.  Which is to say, all of the Propeller chips on the board will (optionally) share a variable frequency main clock source.  Have a look at the datasheet for Maxim DS1077 and you'll have something to drool over :).

Incidentally, this DS1077 chip is controlled by the I2C protocol but that's not why I'm talking about I2C.  I'm talking about I2C because I have had some fun and games with implementing the I2C protocol myself in PASM code on the Propeller chip.

I2C, for the uninitiated is a standardised way for two or more chips to communicate over a pair of wires.  The wires are labelled SCL (Serial CLock) and SDA (Serial DAta).  The simplest way to use I2C is to let your microcontroller be the Master device and the chip you're talking to be the Slave.  That's what I was doing, my Slave device was the Propeller's own EEPROM on pins P28 and P29.

I wanted to make my Propeller read the contents of it's own EEPROM and sending all 32Kb of data to the PC over a 57600 baud serial port.  Since the Propeller has no hardware (eg. in-silicon) implementation of I2C, I was forced to bitbang the protocol myself in PASM.  A task that I had a lot of fun with.

The details of this little sub-project aren't terribly interesting apart from one thing... How your handle the SDA line.  Since there can be many (over a hundred) devices on the bus at once, there must be a way to prevent multiple devices trying to pull the line down or pull it up simultaneously (which would cause a direct short circuit and releasing the smoke).

I2C solves this by never letting any device deliberately push SDA high!  Instead, Pull-up resistors are used to allow the SDA line to drift "casually" towards VCC as soon as EVERY device on the bus has ceased to pull the line down to VSS.  Any device can drag the SDA line low to GND, as part of the comms process.

I2C is absolutely fascinating and I urge you all to have a quick look at the protocol, or even have a go at implementing the Master device yourself.  I2C isn't complicated to implement once you understand it's workings.  I managed to get my Propeller to read my EEPROM without any glitches over I2C and the code required to do so is rather small in it's memory footprint.

Why am I reading the EEPROM?  Because I want the pushprop software (C code running on the RasPi) to be able to non-invasively read the contents of the EEPROM remotely.  Between the PC and the EEPROM is the Propeller chip so I have to write a bit of PASM that I can program into the Prop chip (without affecting the EEPROM) that allows the data from the EEPROM to be relayed back to the PC over the same serial port channel!

Later features of pushprop will make this rather esoteric feature obsolete (as I plan to directly drive the Propeller's I2C bus from the RasPi IO pins so I'll be able to talk directly betwen the PC and each EEPROM on the bus).  But it's nice to have other options too :)

Bodge of the week

$
0
0

Today's mail bestowed upon me a precious Maxim part (you may well gasp), a DS1077 to be particular.  A programmable oscillator for use on an I2C bus.  I'm hoping to use this chip in a new PCB design I'm working on and so I wanted to get some results before Monday.  Hmm, that means there's no time to order a breakout board (lack of foresight while I was purchasing said IC).  Dang,what is one to do?

Then I remembered :)

Bodge(TM)*

In a hurry to complete a project?
Too impatient to wait for the postman?
Too much of a tight-wad to buy a proper solution?
...

Then why not try a Bodge?

Yes, Bodge is a quick and cheap alternative to doing things properly!  Eager to risk frying a relatively difficult to obtain Maxim part by hamfistedly prodding away at it for half an hour with pliers, tin snips and a cheap soldering iron?  Then Bodge is for you!!

No more pacing up and down the workshop waiting for a properly designed and manufactured breakout board to arrive, which would no doubt have cost almost as much as the chip itself!!!  No, just dive in and solder on a bunch of random wires to it and just assume everything will go according to plan!!!!

A Bodge representative is in your area now!!!!!

Hey, take a look at this demonstration!!!!!!


*Terms and conditions apply.  Bodge should not be used in automotive, industrial, life-support, aerospace, military or marine applications.  Bodge should not be used by the elderly, the infirm or the pregnant.  Bodge is probably not really a trademark as far as I know.  It would be awesome if it was though.  Availability: dwindling.  My hovercraft is full of eels.

RasPi Model

$
0
0



LINK: RasPi B.skp

Threw this SketchUp file together as part of my latest hardware project.  There are some additional construction lines left in for convenience for those wishing to align components to the connectors and mounting holes on the RasPi board.

I made every effort to ensure that the model is dimensionally as accurately proportioned as possible.  If in doubt check against your own RasPi to confirm.

Enjoy.
Viewing all 70 articles
Browse latest View live