PICAXE 08M Motor Running Indicator

E-mail Print PDF

Living in the country means having certain technology/equipment/stuff that normal city living people don't have.

One of these things is a bore that supplies water for our stock.  This has a 100m (approx) pipe down into the ground and pulls the water up into a header tank.  We had a problem a few months back where the bore died due to old age/splits in the pipe and wear in the valve at the bottom of the pipe.  In reality is was probably performing worse and worse over time until it eventually got to the point where it couldn't fill the header as fast as we were draining it.

The bore is now fixed but this got me thinking.... if I had a way of tracking the pumping time each day it would show a trend and indicate in advance if there were impending problems.

While it is possible to use a hall effect sensor and monitor the current flow to the pump this was getting a lot closer to the 240v power than I wanted to get.

Instead I built a small unit based on a PICAXE 08M and an IR Diode/Sensor that monitors if the motor is running by watching for interuptions from the pump arm.

The output of the unit is a logic level signal that indicates the pump is "running" or "not running".  This signal is used by an AVR/Packet Wacker based board which collects data and makes it available for loading into a MYSQL database for later trend analysis.

The code for the PICAXE 08M is as follows:

' Bore Pump Running Monitor
'
' Checks for regular breaks of the IR bream and provides a running/not running status
' via the status output pin
'
' Pin Assignments:
' 0 = (Out) Serial
' 1 = (Out) Pump running (1=running, 0 = not running)
' 2 = (Out) PWM
' 3 = (In) IR Status
' 4 = (Out) Mode Indicator (1 = setup, 0 = monitoring)

' Constants

symbol C_RUNNING = 1
symbol C_NOTRUNNING = 0
symbol C_AIMTIME = 30
symbol C_WARNTIME = 30
symbol C_SLEEPTIME = 30
symbol P_MODE = 4
symbol P_IR = 3
symbol P_STATUS = 1

' Variable Usage

symbol RUNTRIGGERCOUNT = b1

#picaxe 08m

main:
        ' Configure PWM Pin 2 for 40000hz PWM Output

        pwmout 2 , 24, 50

        ' Initial state is not running until we decide if it is

        low P_STATUS
        RUNTRIGGERCOUNT = 0

        ' First wait until the IR signal is received so we know the installation
        ' is ok and future interupts for loss of signal is caused by the pump arm
        ' breaking the beam

        low P_MODE
startloop:
        if pin3 = 0 then startloop2
       
        ' IR Signal so Mode indicator on and count trigger until the limit is reached

        high P_MODE
        RUNTRIGGERCOUNT = RUNTRIGGERCOUNT + 1
        pause 150
        if RUNTRIGGERCOUNT <= C_AIMTIME then startloop
        goto startloop3

startloop2:
        ' No IR Signal so Mode indicator off and reset trigger count
                       
        low P_MODE
        RUNTRIGGERCOUNT = 0
        goto startloop
       
startloop3:
        ' Tell the installer that the aim should be ok and we are waiting to check
        ' it stays valid for 5 seconds before initializing interupts
   
        RUNTRIGGERCOUNT = 0

startloop4:
        pause 100
        toggle P_MODE
       
        ' If IR lost then restart sequence

        if pin3 = 0 then startloop2

        ' Keep checking while we tell the user

        RUNTRIGGERCOUNT = RUNTRIGGERCOUNT + 1
        if RUNTRIGGERCOUNT < C_WARNTIME then startloop4

mainloop:
        setint %00000000, %00001000
        sleep C_SLEEPTIME
        if RUNTRIGGERCOUNT > 0 then mainloop2
        low P_STATUS
        goto mainloop

mainloop2:
        high P_STATUS
        RUNTRIGGERCOUNT = 0
        goto mainloop

interrupt:
        RUNTRIGGERCOUNT = RUNTRIGGERCOUNT + 1
        setint %00000000, %00001000
        return


The PICAXE code does three things:


  1. It uses PWM to generate the 40000hz signal to modulate an IR LED.
  2. It monitors the output from the IR sensor to determine if the beam is aligned/broken.
  3. It uses an LED to provides an aiming function for initial installation.

All with less than 80 bytes of code... pretty cool eh!

 

Optimizing VMWare Workstation Performance

E-mail Print PDF
VMWare Workstation is a fabulous tool for software demonstrations (and development, testing and maybe even production... but none of these uses are the focus of this entry...).  Many companies including the one I work for use VMWare Images and the free VMWare Player software to provide preconfigured demonstration systems either directly to customers or for the company sales team.

As images get larger and the application/sales team requires Windows XP (suitably licenced of course) in the images for demonstration we started seeing performance issues that didn't exist with our previous Windows 2K Images.

I have found the following VMWare Image configuration settings significantly improve performance:
  1. Use SCSI (not IDE) disks in the image.
  2. Ensure virtual disks are PreAllocated instead of Growable.
  3. Ensure virtual disks are configured as Independant and Persistent.
  4. Prevent memory trimming by adding MemTrimRate=0 to the .vmx file for the image.
  5. Prevent creation of a VMEM file at runtime by adding sched.mem.pshare.enable = “FALSE” to the .vmx file for the image.
  6. Also adding mainMem.useNamedFile=FALSE to the .vmx file form the image.
  7. Disable Networking if it is not required.
The assumption with this configuration is that you are running one VMWare Image at a time and have a host with sufficient available memory so the allocation specified in the .vmx will not cause swapping on the host.

None of this is particularly new... it is all documented in Performance Benchmarking Guidelines for VMware Workstation 5.5.
 

C64DTV in a BTC 9118 Keyboard

E-mail Print PDF

This project is by no means original but the mechanics of building a C64DTV into a BTC 9118 mini keyboard may be of interest to someone....

A bit of history....

I picked up a PAL C64DTV in K-Mart in Sydney (Australia) in December 2005 with great plans to hack it into something interesting (very been much of a gamer).  It is not November 2006 and some progress is finally being made.  As they say on the Mainland Cheese commercials... good things take time (if you are not from NZ check out http://www.duncans.tv/2005/mainland-cheese for a bit of Kiwi culture).

Getting started....

Not being a great gamer I thought it would be a fun project to build the DTV board into a keyboard, add some external storage and use it to get a feel for C64 programming.  Never was much of a C64 user back in the 80's.  I could have powered up the real C64 or C128D in my retro collection but a side benefit of the repacked DTV is I can take it with my on long business trips to occupy a few boring evenings (an emulator would be just too easy!).

Finding a keyboard....

The first step was to find a keyboard with sufficient free space internally to be useful but also small enough to throw in my travel bag.  In New Zealand compact keyboards appear to be relatively uncommon and those that are did not offer much in the way of internal space... not that I would see looking at the online advertising photos anyway.  Even at NZ$ 25 each (approx US$ 15) the project price starts to climb when purchased parts are unusable.

A likely candidate was the BTC 9118 compact keyboard.  This was available from a number of resellers at a good price and a great article by Monty N5ESE showed how one could be used to build a CW keyer.  The best thing about Monty's site was the internal keyboard pictures that gave me a lot of confidence that a C64DTV board could be mounted internally.

Blog_C64DTV_1.JPG

The Internals....

The BTC 9118 cases comprises two halves... the top half contains the actual keyboard and the keyboard controller PCB.  The bottom half contains nothing at all... but is has a very convenient "tray" half of which is empty.

This picture shows the internals of the BTC 9118 with the C64DTV board, a small regulated +5v power supply and power supply connector.

Blog_C64DTV_2.JPG

The Process....

The process I followed to repackage the C64DTV for this keyboard was as follows:

  • Disassemble the C64DTV joystick!
  • Remove the motherboard and unsolder the BAT+,DIS,LED+,E- and joystick wires.
  • Unsolder the Video (Red), Audio (White) and Gnd wires.
  • Test the C64DTV board for size in the keyboard "tray" and use a file to shave a small amount off the board so it fits property.  Refer to the picture below and you will see a vertical line marking the side I shaved.
  • Remove the red LED from the standard C64DTV switch board and mount it directly on the C64DTV board in the LED+ and E- holes.  The flat side of the LED goes on the E- side.
  • To ensure the board sits as low as possible in the "tray" remove C5 (this is the component reference for a PAL board) and reinstall lying sideways against the board.  Be careful with the polarity... -ve on the capacitor goes to the hole with the shaded silk screen.

Blog_C64DTV_3.JPG

  • Remove the keyboard controller board and unsolder the keyboard cable.  Solder a 4 pin header into the controller board where the cable connected and trim the pins so they are long enough to solder to but not too long that they prevent the case from closing completely.
  • Build a small +5v voltage regulator.  I used a 1N4004 diode for reverse polarity protection, a 78L05 regulator and two 1n caps.  This works well with the 8v plug pack I am using.  If you are using a higher voltage plugpack you may need to use a standard 7805 with a heat sink.
  • On the voltage regulator board I also mounted a pushbutton (salvaged from the PCB of an old modem).  When not pressed the behavior is the same as the standard C64DTV power switch being on (GND on the C64DTV is connected to the -ve power supply).  When pressed the behavior is the same as the standard C64DTV power switch being off (DIS on the C64DTV is connected to the -ve power supply).  This works well as a "reset" button.

Blog_C64DTV_4.JPG

  • Wire the inputs of the regulator to the +/- inputs on the DC jack.  I mounted the jack on the rear right hand side of the keyboard.
  • Wire the +5v output of the regulator to BAT+ on the C64DTV.
  • Wire the +5v output of the regulator to VCC on the keyboard controller board.
  • Wire the Gnd output of the regulator to the common pole of the reset button.
  • Wire the Gnd output of the regulator to VSS on the keyboard controller.
  • Wire the normally closed pushbutton output to E- on the C64DTV.
  • Wire the normally open pushbutton output to DIS on the C64DTV.
  • Wire the DA pin on the keyboard controller to TP4 (PAL) on the C64DTV.
  • Wire the CLK pin on the keyboard controller to TP3 (PAL) on the C64DTV.
  • Reconnect the Video (Red), Audio (White) and Gnd wires to the C64DTV.
  • Test it out and when all is running permanently mount the boards in the "tray".

Making it work....

I found that the reconfigured C64DTV worked well once I discovered a few things:

  • PAL boards require CTRL (not K) to be held down during start if you want to end up in Basic rather than the games menu.
  • After startup in Basic my C64DTV board would ignore most key presses and those it recognized would be followed by 'V'.  This happened with all the keyboards I tried so I don't think it is a fault with the BTC 9118.  Pressing the Shift key once would fix the problem.  I have seen only one other reference to this behavior and that is in Hummer DTV FAQ.

Next Steps....

I may just have enough room to fit a 1541-III-DTV.... and maybe some joystick connectors.  Watch this space.

 

Ruby really is on Rails.....

E-mail Print PDF

Ruby on Rails is really popular at the moment (no kidding!).... but on http://www.quicktrip.co.nz/railtrack.htm it really is on rails.

 

 


Page 29 of 29

Powered by Easytagcloud v2.1

Contact Andrew Quinn

jaquinn@ihug.co.nz http://twitter.com/jaquinn