News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Simple pulse counter and emitter program

Started by ImmortalPr1nce, September 07, 2013, 01:53:49 AM

Previous topic - Next topic

Paulo

I would still be tempted to use a small micro as it's easy to reprogram if any changes are required (no hardware changes needed)
and it's easy to include a RS232 output with the addition of some code and a MAX232.
A USB to Serial convetor would also work.
This could be a very handy feature for logging.



Paulo

#31
What I have done in the past for a quick and dirty solution to monitoring external pulses
is make a simple keyboard interface and a small script to display the results.

Keyboards are very cheap these days, hack one open and connect the following circuit in
parallel with the "Y" key.



A few notes:

1) Obviously the input pulses cannot have too high a frequency or too short a duration (depends to a certain extent on your telematic repeat rate).

2) The batch script uses the CHOICE command which for some reason is not available in XP (and NT I think) but is in Windows prior to XP and after it.
To get CHOICE for XP, download it here (from Microsoft):

ftp://ftp.microsoft.com/Services/TechNet/samples/PS/Win98/Reskit/SCRPTING/choice.exe
Note that the CHOICE version from the above link has a slighlt different syntax to the standard one, so check the help and modify the script as required.

3) Edit the DivisionRatio variable to the required number.

4) Never bothered to convert the batch file to a proper exe as it serves my needs perfectly without the need for messing about with com ports, USB or the like.


:: ========================================
:Start
:: ========================================

:: Change The DivisionRation variable to
:: required division ratio.
:: I have set it to 4 just for quick testing

cls
@echo off
setlocal EnableDelayedExpansion
set count=0
set DivisionRatio=4

echo Press y to carry on or N to terminate
echo ^|

:: ========================================
:MainLoop
:: ========================================

choice /N >null
if '%errorlevel%'== '1' goto CarryOn
if '%errorlevel%'== '2' goto End
goto MainLoop

:: ========================================
:CarryOn
:: ========================================

set /a count+=1
if '%count%'=='%DivisionRatio%' goto Display
goto MainLoop

:: ========================================
:Display
:: ========================================

echo ^|
echo ^|
echo ######## %TIME%
echo ^|
echo ^|
set /a count=0
goto Mainloop

:: ========================================
:End
:: ========================================

echo Terminated.


To test without the interface, start the batch file, it will wait for input, now press the Y key 4 times, it will display ###### TheCurrentTime.
It will continue in a loop until one presses the N key.

To "catch" faster or narrow pulses it's possible to use a "prescaler" circuit instead.
The total division ratio then becomes PrescalerDivision X DivisionRatio (in the script).
There are limits to this and don't expect to process very fast or narrow pulses.
The script has limitations mainly due to the processing time (writing to screen and so on) and also the response time of the keyboard buffer
but as a quick method to monitor an event and perhaps log to file it works a treat.



dedndave

yikes !   :icon_eek:

just hook it up to a serial port   :P

stay away from my soldering iron, Paulo - lol

dedndave

a while back, Marinus mentioned something about using the sound port as an A-D converter
that has possibilities, too
all you need is a decoupling capacitor...
...and some FFT code   :P

Paulo

Quote from: dedndave on September 10, 2013, 08:05:43 PM
yikes !   :icon_eek:

just hook it up to a serial port   :P

Of course a serial port or even LPT is a better choice but not many PC's have them these days and guaranteed a USB to serial is never at hand when needed.
Plus to monitor a single slow frequency event, programming the serial port is much more effort.  :biggrin:
First did this many years ago and still have the old (PS2) keyboard with the opto inside and a RCA connector sticking out the back to enable me to connect all
sorts of interface circuits to it.
Still use it every now and again.

Plus these days one can pick up a USB keyboard for about 5 bucks.
Every experimenter should have one of these.  :biggrin:

Quote from: dedndave
stay away from my soldering iron, Paulo - lol

Don't worry, I have a nice Weller Soldering station.  :biggrin:

Paulo

A sound card is also feasible and especially the new ones that support 192KHz sample rate.
Still can't beat the old batch script + hacked keyboard for simplicity though.  :P

dedndave

the line input port has a lot of possibilities
may have to play with that, some day

Paulo

Another possibility is the VGA output, yes VGA.
It has I2C on two of the pins (15 and 12) which is used by the OS to get monitor info.
As far as I know the OS always checks the monitor capabilities at a fixed I2C address (0x50 if I remember correctly)
so theoretically one could put other I2C chips (set to different addresses) on the bus and the OS would not find them but an app written especially could.
There are lots of I2C chips available ranging in function from attenuators to output latches.
In "the other OS" it's not too difficult to do, don't know how to in Windows though.

Siekmanski

Hi Paulo,
What about using FTDI chips to communicate via USB with your hardware?
I use the FT232RL often to communicate with ATmel microcontrollers.
You can bitbang in high speed.
Data transfer rates from 300 baud to 3 Mbaud (RS422, RS485, RS232 ) at TTL levels.
The FTDI chip has an internal timer and fifo buffers, so no need for a windows timer, just set the transfer rate you need.

http://masm32.com/board/index.php?topic=1239.msg12113#msg12113
Creative coders use backward thinking techniques as a strategy.

dedndave


Siekmanski

Hi Dave,
I've got 2 of those breakout boards with that chip, but nothing done with it yet.
Done some experiments with a bluetooth chip (BTM222), they work like a charm.  :biggrin:
Creative coders use backward thinking techniques as a strategy.

Paulo

#41
Quote from: Siekmanski on September 11, 2013, 12:23:48 PM
Hi Paulo,
What about using FTDI chips to communicate via USB with your hardware?
I use the FT232RL often to communicate with ATmel microcontrollers.
You can bitbang in high speed.
Data transfer rates from 300 baud to 3 Mbaud (RS422, RS485, RS232 ) at TTL levels.
The FTDI chip has an internal timer and fifo buffers, so no need for a windows timer, just set the transfer rate you need.

http://masm32.com/board/index.php?topic=1239.msg12113#msg12113

I quite like the FT232 and have also used the 245 (parallel version).
Another nice interface chip is the ENC28J60 stand alone ethernet interface with SPI port.
http://ww1.microchip.com/downloads/en/devicedoc/39662a.pdf

The reason I posted the other circuits is that I enjoy unusual ways of interfacing computers with real world devices.
One of the whackiest was back when the top of the range computer was a 286 and a friend that owned a small store wanted motion detection on the CCTV system
which would trigger an alarm, log the date and time and also start a VCR to record for a few minutes.

He had one camera covering the back door and another for the front of the store.
I got an LDR plus small suction cup and placed it on the CCTV monitor covering the required area.
The LDR was connected to a comparator and an edge detector so when the picture content that the LDR was "seeing" changed, it would give an output to the LPT of the computer
which would log the date and time and also trigger a VCR to record for a few minutes.
All programmed in either GWbasic or Qbasic, can't remember which.

He was very happy and told a few other people.
I landed up selling a few of these crazy setups and made a few bucks in the process.

These days one can get a complete CCTV system with DVR for several hundred bucks but back in the day, can you imagine getting a 286 to grab video, do line selection then analyze that data.
It would take for ever.

The circuit went something like this:


K_F

Quote from: dedndave on September 10, 2013, 03:55:11 AM
.. but i have been playing with CMOS for about 35 years - lol
Usefull things CMOS..
This XRF machine we had, leaked coolant (water) every now and then, which would blow the Xray tx.
The water would flood the floor under the machine and of course nobody would be able to see this.
The company quoted some ridiculous price for replacement parts, which were not necessary.

Brite spark here, got a PP9 battery.. 1x CMOS chip (cannot remember which), vero board, piezo buzzer, and 2x short brass rods that extended out of this small plastic box onto the floor.
Essentially it was a touch sensor which set off the piezo... water contact did the same thing. Placed this under the machine where the water usually flooded.
The battery lasted 2 years at my last check.. then I left. They never blew another transmitter. The cost might have been 2USD, but it saved 1000s of USDs
A simple very low power cmos device...
:)

'Sire, Sire!... the peasants are Revolting !!!'
'Yes, they are.. aren't they....'

georg

Quote from: Paulo on September 11, 2013, 05:36:37 PM
Quote from: Siekmanski on September 11, 2013, 12:23:48 PM
Hi Paulo,
What about using FTDI chips to communicate via USB with your hardware?
I use the FT232RL often to communicate with ATmel microcontrollers.
You can bitbang in high speed.
Data transfer rates from 300 baud to 3 Mbaud (RS422, RS485, RS232 ) at TTL levels.
The FTDI chip has an internal timer and fifo buffers, so no need for a windows timer, just set the transfer rate you need.

http://masm32.com/board/index.php?topic=1239.msg12113#msg12113

I quite like the FT232 and have also used the 245 (parallel version).
Another nice interface chip is the ENC28J60 stand alone ethernet interface with SPI port.
http://ww1.microchip.com/downloads/en/devicedoc/39662a.pdf

The reason I posted the other circuits is that I enjoy unusual ways of interfacing computers with real world devices.
One of the whackiest was back when the top of the range computer was a 286 and a friend that owned a small store wanted motion detection on the CCTV system
which would trigger an alarm, log the date and time and also start a VCR to record for a few minutes.

He had one camera covering the back door and another for the front of the store.
I got an LDR plus small suction cup and placed it on the CCTV monitor covering the required area.
The LDR was connected to a comparator and an edge detector so when the picture content that the LDR was "seeing" changed, it would give an output to the LPT of the computer
which would log the date and time and also trigger a VCR to record for a few minutes.
All programmed in either GWbasic or Qbasic, can't remember which.

He was very happy and told a few other people.
I landed up selling a few of these crazy setups and made a few bucks in the process.

These days one can get a complete CCTV system with DVR for several hundred bucks but back in the day, can you imagine getting a 286 to grab video, do line selection then analyze that data.
It would take for ever.

The circuit went something like this:



hey man that's classified!!  :dazzled:

georg

it's a very cool idea, but really I need to cover some wide area, not only CV, but also is useful speech recognition in my case