Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 15:46 11 Nov 2025 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : Micromite Input/ Output

Author Message
carlm
Newbie

Joined: 31/05/2018
Location: Australia
Posts: 10
Posted: 06:34am 25 Jun 2018
Copy link to clipboard 
Print this post

Hi,
I am new to the Microprocessors external hardware and need a hand.
I have written a bit of a Functional Description/ Requirements here.

I am independently using 12V and making it into 5V. I then feeding this into the 5V and GND pins of the Micromite. A 3V3 supply then comes from the 3V3 pin.

I need to turn a Micromite Input (Pin 17) on when I get an external 12V pulse.
It needs to go low when the 12V is turned off.

So far I have read that from the 12V Pulse, I feed it through a 10K resistor and then to the input pin (Pin 17). Between the Resistor and the input a shotkey diode is placed with the point at the 3V3 Rail (From the MM Pin 3V3).


With an MM output, I need to switch 12V/24V
Pin 16 is an output that I am energising by code. I have been told that an XC-4488
24V 5A MOS Driver Module is a cool device that I could use to do the job.
It has 3 pins to connect:
Sig
VCC
GND

and 4 screw terminals:
V+
V-
VIN
GND

I have a bit of an idea on how to deal with this section but it would be mostly guess work. Is anyone available to guide me firstly on the input and then the output.
Thank You.
Carl.




 
panky

Guru

Joined: 02/10/2012
Location: Australia
Posts: 1116
Posted: 01:00pm 25 Jun 2018
Copy link to clipboard 
Print this post

Carl,

Regarding detecting a 12 volt input pulse, I suggest setting the input pin to generate an interrupt on low to high and also high to low - check the MM manual on how to set this up ( page 38 onwards ). In the interrupt routines you could set a flag to indicate 12 volts was detected and in your main program, check if the flag is set and take whatever action needed.

Regarding an output to drive something, this depends on what you want to drive. Note that the Micromite outputs are limited on how much current they can drive so generally, it is best practice to use a transistor or mosfet to drive a relay which in turn activates whatever device you are trying to control.

See this thread for a discussion on interfacing relays.

panky

... almost all of the Maximites, the MicromMites, the MM Extremes, the ArmMites, the PicoMite and loving it!
 
Boppa
Guru

Joined: 08/11/2016
Location: Australia
Posts: 816
Posted: 09:48pm 25 Jun 2018
Copy link to clipboard 
Print this post

btw panky, that link doesnt work, it takes you to the microcontrollers index page rather than a specific thread
 
Boppa
Guru

Joined: 08/11/2016
Location: Australia
Posts: 816
Posted: 10:16pm 25 Jun 2018
Copy link to clipboard 
Print this post

jaycar datasheet
These are quite commonly used and a good little pcb

They are pretty easy to hook up, the 4 screw terminals are VIn and GND- these are the + and - from the power supply to the load (anything up to 24v at 5A max) V+ and V- go to the load itself (bulb/motor etc V+ to + and V- to minus if polarity sensitive obviously, a bulb for example wouldnt care)
3 pin signal input is VCC to micromite + rail ie constant 3.3 to 5vdc, gnd is micromite gnd obviously, and signal (sig) goes to the data output pin you are using (16 in your case)

Using just one you could get away with adding it to the 3.3v rail, but if you were using a whole heap, I would think using the 5vdc rail before the 3.3v reg would be a good idea, as those little 3.3vdc regs dont seem to like a lot of current being pulled from them
 
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9751
Posted: 02:32am 26 Jun 2018
Copy link to clipboard 
Print this post

I would be inclined to use a 10k and 3k3 resistor across the 12v pulse, and take the join between the resistors and ground to the MM I/O pin. The 10k/3k3 will form a potential divider, so the I/O pin only sees about 2.9v for your 12v input which just gives a bit of protection to the I/O pin.

As to code, yes, I agree with Panky. Use an interrupt like this:


SetPin 17,INTB,12v_PULSE
SetPin 18,DOUT
Dim 12v_FLAG as Integer

Do 'Main loop
If 12v_FLAG Then
Pin(18)=1 'Relay on
Else
Pin(18)=0 'Relay off
Endif

'......rest of your main loop code here.....

Loop

SUB 12v_PULSE
If Pin(17) Then
12v_FLAG=1
Else
12v_FLAG=0
Endif
End SUB


This code is untested, but it should work. The idea is that the interrupt will be triggered on any kind of pulse on pin-17, and it will set a flag for the main loop to analyse and act on. With the 'On' pulse, 12v_FLAG will be one, and when the 12v pulse vanishes from the input pin, this will again trip the interrupt, and this time it will set 12v_FLAG to zero. The main loop will analyse that flag and switch the relay off and on whenever there is a pulse on pin-17.

We do it this way, as you don't want to hang around in the interrupt actually doing anything. We just set a flag and exit, as this makes the interrupt complete very fast. The main loop can do whatever needs to be done by checking various flags. 'Thou shalt not hang around in interrupts'
Smoke makes things work. When the smoke gets out, it stops!
 
JohnS
Guru

Joined: 18/11/2011
Location: United Kingdom
Posts: 4126
Posted: 04:52am 26 Jun 2018
Copy link to clipboard 
Print this post

I think names can't start with a digit, so may need things like
FLAG_12V and PULSE_12V
instead of 12V_FLAG and 12V_PULSE

but the idea looks sound.

JohnEdited by JohnS 2018-06-27
 
PeterB
Guru

Joined: 05/02/2015
Location: Australia
Posts: 655
Posted: 05:53am 26 Jun 2018
Copy link to clipboard 
Print this post

G'Day Carl
If the 12V is a bit of an unknown you may be better off using an opto-isolator on your input to ensure no damage and reliable operation.

Yes, I know, I'm an old fuddy duddy.

Peter
 
MicroBlocks

Guru

Joined: 12/05/2012
Location: Thailand
Posts: 2209
Posted: 07:21am 26 Jun 2018
Copy link to clipboard 
Print this post

My preference is to always use an optocoupler.
For the input and the output.
It completely isolates the microcontroller from the outside world.
Only connect input/outputs directly or with a common ground if you have some control over it or are absolutely sure it will behave as it should.

Microblocks. Build with logic.
 
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9751
Posted: 07:46am 26 Jun 2018
Copy link to clipboard 
Print this post

JohnS might be right - untested.
Peter B & MB are right. Probably a good idea to use an opto. I have started using them more and more for that kind of thing.
Smoke makes things work. When the smoke gets out, it stops!
 
PeterB
Guru

Joined: 05/02/2015
Location: Australia
Posts: 655
Posted: 08:07am 26 Jun 2018
Copy link to clipboard 
Print this post

G'Day again.

On the subject of the XC4488.
The 4488 may or may not have a clamp diode fitted.
If not, and you are going to drive an inductive load e.g. a relay, you may need to add one.

Peter
 
Print this page


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025