| Author |
Message |
pcleats
Joined: 12 Dec 2005
|
|
Posted: 13 December 2005, 1:59 AM Post subject: 1 button |
|
|
Hello,
I am new to micro controllers and I am wanting to create a video
switcher, and I need to be able to switch from one source to the
next source by pushing a single button. The logic table is:
a0 a1 Channel out
--------------------
0 0 0
0 1 1
1 0 2
1 1 3
I am using a max 454 50MHz (4:1) Video Amplifier and Mux to control
the source input
What is the best way to do this
I could do this with a 4017, but I want to display the info on an
LCD display.
Thanks for the help.
Patrick
|
|
| Back to top |
|
 |
dkinzer Site Admin
Joined: 03 Sep 2005
Location: Portland, OR
|
|
Posted: 13 December 2005, 3:10 AM Post subject: |
|
|
The solution to this problem depends a lot on what else needs to be done by the processor. In the simplest case, the processor is dedicated to detecting the press and release of the "next channel" button. You'd need code to read the switch state using GetPin(), increment the channel selector value, output the select value to two I/O lines that drive the video mux, and finally, wait for the switch to be released. There are some minor issues to deal with as well, e.g. dealing with contact bounce on the switch.
If the processor needs to be doing other things, the solution becomes a bit more complicated. In this case, perhaps it would be best to connect the "next channel" switch to one of the interrupt inputs of the ZX-24 and dedicate a separate task to responding to the switch closure.
If you tell us more about the entirety of what you want to do, a better solution may be suggested. It will also be helpful to let us know how much you already know about the solution (or parts thereof) and your experience level (e.g. hardware, software, etc.) so we don't describe the solution in either too much or too little detail.
|
|
| Back to top |
|
 |
pcleats
Joined: 12 Dec 2005
|
|
Posted: 13 December 2005, 19:08 PM Post subject: 1-button |
|
|
The project has come about because I have a video capture system that captures 16 channels of real time video. The problem that has been presented to me is that I need the ability to see as many as 24 cameras. I don't need to see them all the time. For example if I know a section is not going to be used I can switch to a different set of cameras. At least 12 of the cameras are always used.
I will need to build 4 units that will allow me to decide the set of cameras I am going to use.
I know a bit about the max454. I don't really need more then a 4 channel unit. I just need 4 4 channel units.
I want to be able to quickly switch from camera to camera. A push button seems like a reasonable way to do this. As I said a 4017 would do the job, but I want to be able to display information on an lcd display and the camera that is currently active. Also I would like to be able to switch from manual mode to automatic and then use a set of switches to determine the amount of time a camera is active.
I already know how to make the max454 do what it needs to do, I'm just not sure what I need to do the make the microcontroller do what it needs to do. I don't know much about programming (yet) I still get confused about where things need to go. I have been doing electronics for a few years. Just very new to programming and microcontrollers.
See attached for a visual concept
Thanks for the help.
Patrick
| Description: |
|
 Download |
| Filename: |
Video switcher.JPG |
| Filesize: |
54.25 KB |
| Downloaded: |
1803 Time(s) |
|
|
| Back to top |
|
 |
dkinzer Site Admin
Joined: 03 Sep 2005
Location: Portland, OR
|
|
Posted: 13 December 2005, 22:28 PM Post subject: |
|
|
With most embedded systems, you can make tradeoffs between hardware and software. For example, you could use an external counter clocked by a de-bounced switch and feed the low two bits to the video mux. You could feed those same two bits to the processor so that it could update the display to match.
On the other hand, you can have the processor detect the switch state-change, update an internal counter, output the two low bits to control the video mux and update the display. If you did this, you can make the code simpler by using the two least significant bits of one of the ports for the video mux select outputs. Here is a simple routine that increments the counter value and outputs it:
| Code: |
Private vidSource as Byte
Private const vidSourceCount as Byte = 4 ' must be a power of two
Public Sub NextVidSource()
vidSource = vidSource + 1
If (vidSource >= vidSourceCount) Then
vidSource = 0
End if
' output the video source selector code
Register.PortC = (Register.PortC And Not (vidSourceCount - 1)) Or vidSource
' add code here to update the display indicating the current video source
End Sub
|
The line referring to PortC updates the selection code by reading the current port value, masking off the low 2 bits and adding the current selection code.
You'll also need some code to initialize the video selector value, and to initialize the low 2 bits of PortC to be outputs.
As for detecting the switch closure requesting a camera change, you'll want to configure the I/O pin to be an input with pullup active and connect the other side of the switch to ground. Your code should then periodically look for a logic zero on that I/O pin (using GetPin()). When it sees the logic zero, you can call the NextVidSource() subroutine and then wait for the input to return high, indicating that the switch opened. Note that you'll either have to debounce the switch externally (using an S-R flip flop and a SPDT switch) or do the debouncing in software. To do the latter, it is generally sufficient to delay for 30-50mS after the switch change is detected before re-sampling the input. Most switches have a contact bounce specification less than this amount.
Perhaps this will get you started. If you have other questions, ask. You might want to pick up a book entitled "Physical Computing" by Dan O'Sullivan and Tom Igoe. It give a very good "ground up" introduction to both hardware and software for microcontrollers. In most sections, they give example code in BasicX that can be used directly in ZBasic.
|
|
| Back to top |
|
 |
|