Archive for the ‘Code’ Category

8Mhz….

Wednesday, March 24th, 2010

Yesterday I made the switch to running the Picaxe chips at 8Mhz. Whilst the guns function fine at 4Mhz, they had problems registering all the hist from the Minigun as it shot faster than the guns could process the hits. Also as the code gains more features it will only get slower, I decided now was a good point in time to boost the speed.

Aside from some minor issues like reloading being two fast and all the sound statements being higher pitched the transition went quite smooth and the guns now pick up all the shots from the mini-gun. This leads to another problem that the mini-gun can kill players even quicker now!!!!

Persistent Game State

Sunday, March 7th, 2010

One of the major flaws with the LibreTag system in its current state is that if the power is turned off mid game all the variables containing the players health and remaining ammo are lost. This can either be an annoyance or a way to cheat, either way it needed to be fixed.

I toyed with several ideas like saving all variables to the built in EEPROM every 10 seconds or so, but I was worried that after a while I may wear the EEPROM out. There is also the disadvantage that since the save is happening every 10 seconds people could still cheat in that time window. I finally came across the idea of getting the Picaxe chip to detect when the power is turned off and then save all the variables to EEPROM. By using a large capacitor (2000uf) on the 5v supply line, the Picaxe gets just under a second of runtime before the voltage drops too low.

I initially tried lower capacity capacitors but it was only at about 1500uf that the picaxe managed to stay on long enough to detect the power loss. I created a simple IF statement, once the input voltage dropped below about 5.5v (I’m using a 5v LDO regulator) it went into a loop sending a test character out the serial connection to the pc till the power completely dies. During testing what I saw was really strange since at 1000uf nothing was received, but when using a 1500uf capacitor,  about 20 characters were received. I would have expected that when using a 1000uf to at least get a couple of characters received, I am guessing this is to do with the logarithmic nature of a capacitor.

Anyway like I said with a 2000uf capacitor the Picaxe stays on for long enough to save the health, ammo and number of remaining clips to EEPROM. With a few more modifications to the code, the gun now reads these values back out at power on and hence the game state is preserved. The only thing now is that I have to re-flash the gun once the health or ammo is depleted, which means I better get working on the Admin box to remotely configure the guns…..

Adjustable Power

Monday, December 21st, 2009

Since I first built a working circuit for the LibreTag project, I always found that testing indoors proved to be without any need of aiming. My walls are white and so much IR is generated by the IR LED,that you can almost point the gun in any direction and score a hit.

I have been thinking of ways to be able to scale the power output of the guns down depending on where you intend to use them. My best idea so far was to use another FET to switch the IR LED either through a ~100 ohm resistor or straight to ground, to give a x1 or x1/10th power selection. However the problem with this is that it would never give you a chance to say scale from a large room to a small room.

Tonight I had a brain wave. After glancing over the data sheet for the 38khz IR receivers I noticed that they have a fairly high drop off as the frequency diverges from 38khz. I wondered if I could use this to my advantage by changing the PWM frequency of the transmitting IR LED.

IR LED response curve

I am happy to report it works wonders. I still need to implement a menu option to make the “strength” selectable, but with the freqency set to 50khz the sensitivity of the receiver, as per the graph, drops down to about 20%. It makes the gun usable indoors, with no sign of any reflections. It is maybe a little too under powered at 50khz, but this can be tweaked.

Two new videos of the Libre Tag system

Tuesday, October 6th, 2009

I have uploaded two more videos to youtube showing some features I have just added

Reloading and showing burst and single shot modes

Showing the menu system