Author Topic: PC based sensor troubleshooter  (Read 26390 times)

Offline myelectricbike

  • PhD. Magic
  • ******
  • Posts: 644
    • How to Build an Electric Bike
PC based sensor troubleshooter
« on: August 13, 2007, 05:21:06 AM »
Just finished a prototype, including software, of a PC based sensor troubleshooter. Plug in the cable from the motor, run the program, turn the wheel and you are done. Just now converting the logic to a verbose diagnosis.

The pictures below are of the prototype cable circuit and connection, and program output.

Classic SPP Centronics Printer Port
« Last Edit: August 14, 2007, 01:34:08 PM by myelectricbike »

Offline myelectricbike

  • PhD. Magic
  • ******
  • Posts: 644
    • How to Build an Electric Bike
Re: PC based sensor troubleshooter
« Reply #1 on: August 13, 2007, 10:21:01 AM »
Version 1.1 on the way...

While your sensors may test good it is possible you may have a weak, broken or missing magnet in which case an anomaly will appear as the condition passes the sensor array and is recognized by the troubleshooter software at the exact rotational angle it occurs.
« Last Edit: August 14, 2007, 12:51:00 PM by myelectricbike »

Offline ahend

  • Confirmed
  • Magic Undergrad
  • ***
  • Posts: 58
Re: PC based sensor troubleshooter
« Reply #2 on: August 13, 2007, 02:58:31 PM »
Great idea, it looks to be working nicely.
If you don't mind me asking, what type of PC interface are you using for I/O and what programming language are you coding in?

Earlier I made a device to capture discharge curves from my NiMH cells using a Labjack, a simple SSR circuit, and Visual Basic.

Fun stuff

Offline OneEye

  • Confirmed
  • Master of Magic
  • *****
  • Posts: 261
Re: PC based sensor troubleshooter
« Reply #3 on: August 13, 2007, 04:27:13 PM »
Nice.  With sensor troubles being one of the #1 problems being reported on the forums this could be a very useful tool.

Is this going to be one of your pre-shipping Q/C checks?  Also, are you going to keep this as myelectricbike value-added / proprietary information, or do you intend to public source the code and hardware build?  Just curious, I'm not pushing either way.

-Mike


Offline mustangman

  • Confirmed
  • Bachelor of Magic
  • ****
  • Posts: 221
Re: PC based sensor troubleshooter
« Reply #4 on: August 13, 2007, 06:27:52 PM »
 May I suggest a USB I/O connection since the USB is only 5V max output and almost every computer, high end calculator, PDA, etc.... has a USB port.(the program could be written for mutiple platforms) This tester would be a great addition to the DIYer to find those pesky quirks when troubleshooting. Keep up the great work!! :)

Offline OneEye

  • Confirmed
  • Master of Magic
  • *****
  • Posts: 261
Re: PC based sensor troubleshooter
« Reply #5 on: August 13, 2007, 06:49:24 PM »
My bet is the early prototype modeled here is a directly wired parallel port hack.

ahend, have you seen any open source open hardware implementations of the LabJack you are using?  Looks like a great tool, I'd be surprised if someone hasn't already taken the idea and created a DIY creature from it.

Offline myelectricbike

  • PhD. Magic
  • ******
  • Posts: 644
    • How to Build an Electric Bike
Re: PC based sensor troubleshooter
« Reply #6 on: August 13, 2007, 11:35:58 PM »
Some background... I started hacking PC's after I got my first TRS-80 Model I. The RS manual actually came with a description of how to use the cassette on/off switch to turn a coffee pot on and off automatically!  ;D Later I moved to X-10 technology, but that's another story.

I used the Centronics (SPP) printer port to build a sonar unit with little more than assembly code, a microphone and speaker. I then hacked the mouse and game ports for more digital and analog input fun and then the keyboard and finally the serial port. I still have the remnants of various wedges and video capture devices, etc. that used the various ports.

I bought a 12 bit A/D converter and used it for all sorts of bench top stuff and finally retired it to a role doing home security by monitoring and recording the outputs from various IR, pressure, temperature and other sensors and switches.

When Windows XP came along with its greatly improved motion detection capability the A/D converter was again available for a digital input so...

The reason I decided to use a printer port was because it was the easiest of all the methods I had used before - until XP that is.

I'm not sure about the software that comes with the USB to Parallel converters that run as little as $10, but if they support reading and writing of raw digital data to and from the port then they can be used as well.

Essentially all this circuit does is to use 10K pull up resistors to keep the Hall Effect sensor output and the Centronics line level input from floating when not active so you get true binary input and nothing else. You can also substitute any 10ma LED and resistor combo to replace a volt meter to read the sensor output by lighting up an LED for manual input into a PC. Be sure to limit the current required to sink the LED's to 10ma unless you add a transistor since this is the current limit the Hall Effect sensors can sink.

Centronics lines 10, 12 and 13 (Acknowledge, Paper Out and Select) are used for input with blue, green, yellow respectively.

If you have an old PC running anything prior to XP then you can use Qbasic or Visual Basic to read port 889. For XP it is virtually impossible (although I did find a proprietary method and I am developing one hinted at by Microsoft tech).

From there its just a matter of doing with the data whatever you want to do. The only thing my software does that might be special is the logical equation it produces from the results and the interpretation of what the equation means for verbose output of any shorts, opens, intermittents, bad mags, etc. that the analysis discovers. One other thing is the graphic which tells exactly when and where a problem occurs.

I will post a circuit diagram here shortly and I have 30 Centronics printer cables on order in case you don't have one of your own. (These things cost $44 each in 1978 but only a dollar or two now.)

And yes, Mike, my primary and intended use for this circuit is now to test whatever outgoing bikes I sell, but was originally intended to help pinpoint a sensor or wiring problem prior to taking a motor apart as the result of various conditions I am subjecting the motor to, although interestingly enough it appears that 10 minutes after testing or 10 seconds after hitting a bump or pothole a previously undiscovered problem can appear.

Anyone know if the USB to Centronics converter cable allows raw digital data to be transfered to and from the printer and if the software that comes with it handles the conversion?
« Last Edit: August 19, 2007, 06:43:30 PM by myelectricbike »

Offline ahend

  • Confirmed
  • Magic Undergrad
  • ***
  • Posts: 58
Re: PC based sensor troubleshooter
« Reply #7 on: August 14, 2007, 01:01:52 AM »
Quote
The reason I decided to use a printer port was because it was the easiest of all the methods I had used before - until XP that is.

I agree, the old Centronics parallel port was a great interface until NT/XP locked it up.  My last foray involved the use of inpout32.dll with XP and ended in disappointment. Having built a small CNC machine and a homebrew/kit 3 axis motion controller for steppers, I put some VB code together to read NC code and spit out motion commands via the parallel port to the controller. The system worked well in homing and positioning but was somewhat spastic in multi-axis motion because I could not gain real mode control of the port. Windows would bump in and interrupt, screwing up any chance of accurate timing or sequencing.

Quote
ahend, have you seen any open source open hardware implementations of the LabJack you are using?

There are a few DIY USB interface projects floating around the web but they require burning EPROM’s or microprocessor memories. It’s fascinating stuff but without the right tools you can’t go very far.

A couple prominent examples:

http://www.create.ucsb.edu/~dano/CUI/

http://www.e.kth.se/~pontusf/usb2lcd.html

I've been happy with my Labjack. The price ($100) is not too bad and there is a full ActiveX interface so programming is fairly seemless. The only complaint I have is that my laptop limits USB current to around 50ma. When you split that up among the digital outputs, you don't have a lot of relay or LED driving power. Even so, that can be overcome with an external power source - it's just a bit more of a hassle.
« Last Edit: August 18, 2007, 01:40:04 AM by ahend »

Offline myelectricbike

  • PhD. Magic
  • ******
  • Posts: 644
    • How to Build an Electric Bike
Re: PC based sensor troubleshooter
« Reply #8 on: August 22, 2007, 03:47:37 PM »
I checked out both links but did not get a response from either one. The create link looked great except that when I went to buy parts for the DIY project most everything was listed as unavailable or obsolete which makes me think the author really wants you to buy his finished board rather than to build one of your own.

USB is eventually the way this will go but for now I wanted to get it up and running. With that in mind I tried the circuit out under WIN98se and was able to read the printer port status with no gaps or delays from running inpout32.dll under WINXP so I went ahead and ordered enough parts to build 30 sensor readouts. The revised circuit will be mounted on the bike so the blue, green and yellow LEDs can be viewed to monitor the sensors while riding and will also have a connector to allow the readout to be input into the computer and the logic analyzed.   

Offline ahend

  • Confirmed
  • Magic Undergrad
  • ***
  • Posts: 58
Re: PC based sensor troubleshooter
« Reply #9 on: August 22, 2007, 05:00:04 PM »
When you have things nailed down, you may want to look at USB to Parallel interface cables. They are equipped to emulate a bi-directional parallel interface with the supplied Windows 98/XP driver. You could breakout the parallel end of the cable inside your device enclosure, giving your project a clean and convenient (save for the hassle of installing the driver) USB interface. I just ran it past eBay and several affordable examples popped up.

Offline OneEye

  • Confirmed
  • Master of Magic
  • *****
  • Posts: 261
Re: PC based sensor troubleshooter
« Reply #10 on: August 22, 2007, 05:36:06 PM »
There is also the avrusb project which implements the USB protocol on an inexpensive AVR microcontroller.  An example datalogging implementation can be found here:

http://www.raphnet.net/electronique/usbtenki/index_en.php

The licensing options include a commercial license if desired, or an open hardware / open source / mandatory documentation license if you wish to avoid paying licensing fees.  Project is at:

http://www.obdev.at/products/avrusb/prjdata.html

Offline myelectricbike

  • PhD. Magic
  • ******
  • Posts: 644
    • How to Build an Electric Bike
Re: PC based sensor troubleshooter
« Reply #11 on: August 22, 2007, 07:47:22 PM »
I saw the USB to parallel printer cables on eBay but was thinking I might still not have real time communication between the hardware and software since the USB LPT route would also require VB.net or VB.2005 to use winspool.dll under WINXP to access printer status.

Since I have now been able to do the input and save analysis using a DOS executable (Win98) I know I can do it with the hardware so I won't need the computer for anything now except permanent storage and possibly display of the analysis and data. With the hardware doing the analysis, upload speed is no longer an issue.

Using hardware to input, analyze and store the data for later upload to the computer also opens up other methods like a keyboard, mouse or even a joystick or microphone wedge for upload of the data.
« Last Edit: August 23, 2007, 01:20:50 PM by myelectricbike »

Offline ahend

  • Confirmed
  • Magic Undergrad
  • ***
  • Posts: 58
Re: PC based sensor troubleshooter
« Reply #12 on: August 22, 2007, 11:00:55 PM »
I just purchased one of the USB to parallel converter cables off eBay. When I have it I’ll check out the bitwise I/O capability from XP using inpout32.dll and VB6.
Your LED interface is simple and quick, and there is certain elegance to that for sure. Something else in the same vein that would be neat is a couple TTL AND gates biasing a small signal transistor to “pop” the output through a small speaker or piezo disc. All three outputs would have to be present to get the audio. You could listen for any gaps!

I think I’m going to dig out my Basic Stamp and see how easily I can make a self contained data-logger. You had expressed interest in that in another thread and I too thought that capturing dynamic voltage discharge curves could really help identify battery issues. Perhaps it would lend itself to your current project as well. Parallax offers OEM Basic Stamp parts that could make things a bit more affordable.

Offline myelectricbike

  • PhD. Magic
  • ******
  • Posts: 644
    • How to Build an Electric Bike
Re: PC based sensor troubleshooter
« Reply #13 on: August 23, 2007, 07:08:56 AM »
Since my old laptop runs WIN98 and has a printer port the USB to printer cable will not be required for further prototyping but could be required for production units to assure access by computers limited to USB port and XP.

However, now that I have been able to revise the hardware at very little additional expense ($5) to handle both the sensor input and analysis, and real time upload of data (some of which is ignored by the WINXP and prevents accurate analysis) is no longer necessary, neither the type or speed of the computer interface is an issue.

The individual battery monitoring system could be done with a stamp and possibly at less expense or hardship that doing it with hardware alone. All depends upon whether knowing that a particular battery is approaching 10.5 volts faster than the others by method of using a few in-line LEDS versus viewing the discharge rates by LCD display is the way you want to go. Doing a VU meter LED indicator for each battery might suffice in place of a 2 axis curve displayed on an LCD screen at far less expense. Besides the screen on my laptop has a weird connection problem that gets worse when joggled around.

The revised sensor status indicator circuit shown below also uses a bargraph in its simplest form in place of a computer or stamp and LCD display. The bargraph readout allows the rider or the tech to look up the status of the sensors on a code sheet to determine if the sensor power supply or the sensor leads have opens or shorts or if the sensors themselves are not working. 

« Last Edit: August 30, 2007, 10:26:01 PM by myelectricbike »

Offline myelectricbike

  • PhD. Magic
  • ******
  • Posts: 644
    • How to Build an Electric Bike
Re: PC based sensor troubleshooter
« Reply #14 on: August 30, 2007, 06:15:36 PM »
Prototype layout is ready for a one-of low cost circuit house... got any pointers? I'm all out of  Press-N-Peel.
« Last Edit: August 30, 2007, 07:30:29 PM by myelectricbike »