MilesTag

Open Source Laser Tag => Open Source Lounge => Topic started by: nuclearsummer on April 26, 2012, 03:04:13 AM

Title: RaspCORE - Raspberry PI Lasertag-System (my ideas)
Post by: nuclearsummer on April 26, 2012, 03:04:13 AM
Hey guys,

in the last months I have heared a lot of interesting news about the Raspberry Pi platform (http://www.raspberrypi.org/faqs (http://www.raspberrypi.org/faqs)).
So why dont use it as a mainboard in a Laser gun?

It is very cheap (25$ - 35$) and linux run on it.
You dont ne a complex Linux distribution like Fedora or Debian, an optimized Arch-Linux would be more suitable.

Pros:
+ a lot computing power (700MHz)
+ cheap and tested
+ energy efficient (25$ -> 2.5W; 35$ -> 3.5W)
+ run with batteries
+ sound support and audio out
+ sd card can store soundfiles
+ GPIO Port to control LEDs, display or react with switches
+ USB Support: so you can run a 5$ BlueTooth adapter to communicate with other devices
+ maybe easier developing and testing

Cons:
- Linux brings more complexity
- maybe it is impossible that Raspberry Pi bring 1.5A direct to the IR-LED, so a small second PCB is needed.
   An idea is that the Raspberry Pi create the MilesTag-Datagram, send it to the second PCB and this fire it out.
- maybe more power consumption than an arduino/MilesTag-System
   
This is just the result of my brainstorm.
I am really interested in comments from the MilesTag-community  :)

thanks

howdy!
Title: Re: RaspCORE - Raspberry PI Lasertag-System (my ideas)
Post by: berk on April 26, 2012, 04:17:49 AM
You'd have to write a Linux kernel module to get the 600uS pulse timings accurate. If someone could do that, I do not see any reason why it could not be done.
Title: Re: RaspCORE - Raspberry PI Lasertag-System (my ideas)
Post by: nuclearsummer on April 27, 2012, 04:38:25 AM
Hey berk,

why should my code in a kernel-module?
That the 600us-clock-process get a higher priority?

In my view that is not needed.

The RaspCORE have reduced set of processes. No gui, few system-programms, optimized Kernel.
In combination with a highest priority (nice = -20) of my programm will react very fast.

The detection of the 600us is no problem, linux (time.h) can return the systemtime in nanosecounds.
So I meter permanent the time and if 600us are over, a new event is happend.

BTW: Some Rasp Pi distributions have a config file where it is possible to change cpu frequency and current, disable 3d acceleration ...  ... these optimizion can increase the runtime with batteries.

sorry about my bad english :)

howdy
Title: Re: RaspCORE - Raspberry PI Lasertag-System (my ideas)
Post by: berk on April 27, 2012, 07:19:32 AM
Hello howdy
  Time can be returned  in uS in Windows too, but the multi  tasking time slice resolution is at best 4mS, and that is not guaranteed.

It is the same with Linux, your process will not be granted an equal amount of CPU time for every time slice, so code like:

Code: [Select]
while(1)
{
if( time_now > time_last + 600uS)
{
   CheckIrInput()
   time_last = time_now
}
}

will not work as any interrupts or processes with higher priority might interrupt your code at any time. It might be 60uS, 600uS or 1200uS before the next thread time slice, and with an asynchronous protocol, once you start to drift you will never re-synchrnoise.

I've written software based timed receivers like this on PICs, but on those I am guaranteed how long each step of the program will take as I control all of the interrupts, and there is only one process: me!

I am not saying it cannot be made to work, but my experience in this field tells me you will need more than a simple process to monitor the data stream.

Tony
Title: Re: RaspCORE - Raspberry PI Lasertag-System (my ideas)
Post by: Delrick on July 25, 2012, 03:59:55 PM

I quite agree about the time slice problem but take a look at Mike Cook's Magic Wand at http://www.raspberrypi.org/archives/1663, of particular interest is the way he gets the timing:-
 
" the BCM2835 chip has an ARM peripheral that can help. It is a free running counter, that means it keeps on going while the operating system steals some time off you. "

Another option would be to use a simple PIC circuit to do the decode and pass characters from a circular buffer to the Raspi with SPI, PIC's are 50p for the smaller ones. I am particularly interested in using a RasPi for a scoring system. It's HDMI and analogue Video outputs means it could use a TV as display, and with all the other i/o available and the Linux core printers etc are no problem.
Title: Re: RaspCORE - Raspberry PI Lasertag-System (my ideas)
Post by: cjsoftuk on July 26, 2012, 01:13:31 AM
Del, My latest set of projects has exactly that kind of application in mind.....

I'll post more when I'm not working 8AM-8PM.
Title: Re: RaspCORE - Raspberry PI Lasertag-System (my ideas)
Post by: berk on July 26, 2012, 06:05:35 AM
Magic wand is interesting, but it is still polling a timer to determine time periods. Any inaccuracies in timing in this application will simple be missed by the human eye.

Milestag packets have a min. pulse with of 600uS. To parse these with a poll you need to be running at least 2x that speed, and ideally at a 4x. That means you need your software to be looking at a pin every 150uS.

To get this kind of accuracy you really need interrupts, as any drift caused by a task switch will result in missed packets.
Del has the best idea for a slave pic to do the accurate timings, and pass the validated packets onto the Pi for processing.


Title: Re: RaspCORE - Raspberry PI Lasertag-System (my ideas)
Post by: berk on August 03, 2012, 12:17:30 PM
There is now an Adafruit distro for Raspberry Pi which includes SPI and I2C. That would simplify communicating with a PIC.

http://learn.adafruit.com/adafruit-raspberry-pi-educational-linux-distro/ (http://learn.adafruit.com/adafruit-raspberry-pi-educational-linux-distro/)
Title: Re: RaspCORE - Raspberry PI Lasertag-System (my ideas)
Post by: LordAkkrand on August 06, 2012, 08:44:20 PM
I've got a rPi on order (only a few weeks, fingers crossed), and am thinking of doing a similar thing.
My plan was to get a usb->rs232 serial adapter (only ~$2 on eBay), and hook up the sensors to that, and have the lirc daemon do the timing and decoding for me.  I don't know if that will be CPU intensive or not, it's not like I'll be running much else in my python program.
I'm not 100% sure that will work, but the parts to test it out are only a few dollars, and I can begin testing on windows using winlirc whilst waiting for my pi to be delivered.
I'll post my findings when I have some.
Title: Re: RaspCORE - Raspberry PI Lasertag-System (my ideas)
Post by: cjsoftuk on August 07, 2012, 01:55:44 AM
A cool idea to use lirc on the RPi.

Just watch out though:
1) lirc will need a config file written to cater for MT5.
2) lirc may have problems with multiple definitions (which you need for MT5).

Best of luck with it though, and if you get it working, please feed back (and ideally release the definition file).
Title: Re: RaspCORE - Raspberry PI Lasertag-System (my ideas)
Post by: MilesTag on August 08, 2012, 10:03:10 AM
Watching with interest.  My Raspberry Pi has been on order for a few weeks now.  Still waiting...
Title: Re: RaspCORE - Raspberry PI Lasertag-System (my ideas)
Post by: bfisch1983 on November 14, 2012, 01:02:12 PM
You could so something similar to what I had planned for laser tag.  Which uses a central unit on the body or arm for the user input and output and then the guns and receivers are both run by MSP430F2012 (boards with this on them are $3 apiece.)
So the IR TX timing is handled by one MSP430 the receivers have another MSP430.  This way the conflict between shooting and getting hit is removed.  You can link the gun and receivers wirelessly like I planed or use the I2C or SPI interfaces.
This is my planned system architecture.
http://bfisch1983.com/lasertagpages/Architecture.gif (http://bfisch1983.com/lasertagpages/Architecture.gif)
I like this setup because things like custom guns and grenades can be made pretty cheaply and you can have multiple guns per person in a game.
I may just switch the core unit to a raspberry pi because it has all the IO I need and will help me with playing audio.  It looks like you can use QT creator to develop on the pi and for a separate project I already have QT creator on windows reading an XBee over uart and playing sounds with IRRKlang.  Not sure it IRRKlang will port but FMOD might.  Still plenty to look into and think about, but its a good idea.
Title: Re: RaspCORE - Raspberry PI Lasertag-System (my ideas)
Post by: LordAkkrand on August 19, 2013, 08:35:42 PM
So it's been a while, but I've started progressing on this again.

I found several problems with the rPi USB, such that hooking up an IR LED or receiver via a USB cable would result in the USB serial cable device being disconnected the moment I tried to use it.
So, I've started wiring the circuits myself, connected to the GPIO, because the lirc daemon has had gpio support added for the raspberry pi (god bless open source software!).

I used the circuit diagrams provided to me by raspberry pi forum member 'mba' from his blog:
http://www.datscharf.dk/amote/tutorials/lirc-on-raspberry-pi/ (http://www.datscharf.dk/amote/tutorials/lirc-on-raspberry-pi/)
http://www.datscharf.dk/amote/hardware/diy-receiver/ (http://www.datscharf.dk/amote/hardware/diy-receiver/)
http://www.datscharf.dk/amote/hardware/diy-transmitter/ (http://www.datscharf.dk/amote/hardware/diy-transmitter/)

Registering a switch (trigger) tripping is trivial, the circuit is tiny, as is one to power "muzzle flash" LEDs.
And I've got my circuits working, now I just have to fit it into a prototype tagger, whip up a bit of python to listen, and shoot one pi with the other.

I'll update again when I've got more.
Title: Re: RaspCORE - Raspberry PI Lasertag-System (my ideas)
Post by: Pingvin on August 23, 2013, 04:05:42 AM
So it's been a while, but I've started progressing on this again.

I found several problems with the rPi USB, such that hooking up an IR LED or receiver via a USB cable would result in the USB serial cable device being disconnected the moment I tried to use it.
So, I've started wiring the circuits myself, connected to the GPIO, because the lirc daemon has had gpio support added for the raspberry pi (god bless open source software!).

I used the circuit diagrams provided to me by raspberry pi forum member 'mba' from his blog:
http://www.datscharf.dk/amote/tutorials/lirc-on-raspberry-pi/ (http://www.datscharf.dk/amote/tutorials/lirc-on-raspberry-pi/)
http://www.datscharf.dk/amote/hardware/diy-receiver/ (http://www.datscharf.dk/amote/hardware/diy-receiver/)
http://www.datscharf.dk/amote/hardware/diy-transmitter/ (http://www.datscharf.dk/amote/hardware/diy-transmitter/)

Registering a switch (trigger) tripping is trivial, the circuit is tiny, as is one to power "muzzle flash" LEDs.
And I've got my circuits working, now I just have to fit it into a prototype tagger, whip up a bit of python to listen, and shoot one pi with the other.

I'll update again when I've got more.



Great idea!
I find time, be sure to take part in the project (with your permission)!
After all, even video can be broadcast online via 3G modem!
Low-level interfaces - that's it!
Title: Re: RaspCORE - Raspberry PI Lasertag-System (my ideas)
Post by: TCAir on December 03, 2015, 06:57:33 AM
Ok,

So Raspberry Pi Zero is out for $5.  https://www.raspberrypi.org/blog/raspberry-pi-zero/

This makes the fully functional Raspberry Pi competitive with Ardunio for taggers and give alot more capability.

Time to resurrect this thread?

Title: Re: RaspCORE - Raspberry PI Lasertag-System (my ideas)
Post by: Pingvin on December 03, 2015, 07:41:16 AM
Ok,

So Raspberry Pi Zero is out for $5.  https://www.raspberrypi.org/blog/raspberry-pi-zero/

This makes the fully functional Raspberry Pi competitive with Ardunio for taggers and give alot more capability.

Time to resurrect this thread?
Also pay attention to it.
Very interesting!
How much energy it consumes?
Title: Re: RaspCORE - Raspberry PI Lasertag-System (my ideas)
Post by: TCAir on December 03, 2015, 08:20:53 AM
http://www.midwesternmac.com/blogs/jeff-geerling/raspberry-pi-zero-power

0.7W 140mA
Title: Re: RaspCORE - Raspberry PI Lasertag-System (my ideas)
Post by: Pingvin on December 04, 2015, 02:27:44 AM
Too much. :(
It need a whole pack of batteries. :-\
Title: Re: RaspCORE - Raspberry PI Lasertag-System (my ideas)
Post by: TCAir on December 07, 2015, 01:12:10 PM
Is it?

Very Similar to A+
This shows us clearly that the Zero uses pretty much the same amount of ‘juice’ as the A+. This is hardly surprising, given that the processor is the same and there’s not a lot else on either board (just USB keyboard/mouse dongle). They both draw about 100 mA when idle and 140 mA when pushed. It’s possible that the peak current on loading LXDE is a tad higher on the Zero because the CPU is overclocked to 1 GHz and the core L2 cache is also clocked faster – but it could equally just be random measurement error. WJDK!

Voltage under load was 5.09V, so the Pi Zero uses 0.5-0.7 Watts.


(http://raspi.tv/wp-content/uploads/2015/11/Pi-Zero-Power-Usage-Table.jpg)

That power draw is running wide open.
Title: Re: RaspCORE - Raspberry PI Lasertag-System (my ideas)
Post by: Pingvin on December 08, 2015, 01:02:21 AM
In any case - the theme is interesting, promising direction.
If that - I'm on the team. ;) :)
Title: Re: RaspCORE - Raspberry PI Lasertag-System (my ideas)
Post by: racecarparts on May 18, 2017, 01:29:10 PM
Old thread ... but still relevant.

I'm working on this now... but since I'm a Java dev, I'm trying it in Java on a RPi zero w.  First, I tried using pi4j for it all, but it's too slow to pulse the IR in under 600 microseconds. :( Never thought I'd ever run into that kind of problem.  Java is definitely fast enough on the pi zero, but the pi4j lib is not.

Now I'm seeing if I can use diozero http://rtd.diozero.com/en/latest/ (http://rtd.diozero.com/en/latest/) and lircj https://github.com/caprica/lircj (https://github.com/caprica/lircj) on a raspberry pi zero w.  Just started that last night and today.  I'll post stuff here as I go along.