
Ive been making this circuit below and trying to add a low pass filter has ive highlighted in a the red box below but not having much luck with it, you say that the resistor and capacitor as to be in series?.
Moderators: Chuckt, Garth, bitfogav
Brad, yes the second op-amp which is setup to work as a comparator is set to output a logic 0, when a loud sound is generated and amplified to a voltage higher than 1.5v, then the output will go from 0v to 5v until the voltage at the (+) falls below 1.5v? which will give us our logic 0 again.brad wrote:I see the reference is 1.5volts (which would be a logic 0 for the uC) What is a valid logic 1? is it just above 1.5v?
Code: Select all
// Main Program
While true
// Update the LCD Display
LCD.WriteAt(1,1,"CH1 = ",Convert.DecToStr(DMX_Channels(0),3))
LCD.WriteAt(2,1,"CH2 = ",Convert.DecToStr(DMX_Channels(1),3))
LCD.WriteAt(3,1,"CH3 = ",Convert.DecToStr(DMX_Channels(2),3))
LCD.WriteAt(4,1,"Beat = ",Convert.DecToStr(beatCounter,3))
// Fast or Slow Function
If slowFastControl = 1 Then
range = 180
Else
range = 80
EndIf
RandGen2.SetRndMax(range) // set MAX random gen value
If beatInput = 1 And beatDelay = 0 Then
barrelPos = RandGen2.rand () // Get a random number
barrelPos = 128 + ((barrelPos) - (range / 2) ) // set barrel pos depending on our range
DMX_Channels(0) = barrelPos // set channel with value
barrelSpeed = RandGen2.rand () // Get a random number
barrelSpeed = 128 + ((barrelSpeed) - (range / 2) ) // set barrel speed depending on our range
DMX_Channels(1) = barrelSpeed // set channel with value
If colourChanger <= 0 Then
RandGen2.SetRndMax(8) // set MAX random gen value
colour = RandGen2.rand () // Get a random number
Select colour
Case 0 //
colourValue = white //
Case 1 //
colourValue = red //
Case 2 //
colourValue = multi //
Case 3 //
colourValue = magenta //
Case 4 // Select which colour to display
colourValue = green //
Case 5 //
colourValue = yellow //
Case 6 //
colourValue = blue //
Case 7 //
colourValue = pink //
Case 8 //
colourValue = cyan
End Select
DMX_Channels(2) = colourValue // set dmx channel 3 to colour value
colourChanger = 16 // reset our colour changer value
EndIf
Dec(colourChanger) // Decrease our colour changer value
Inc(beatCounter) // Increase our beat counter value
If beatCounter >= 200 Then // Reset out beat counter
beatCounter = 0
EndIf
beatDelay = 50 // set our delay beat detector to help stop false beats
EndIf
If BlackOutOn = 1 Then
// Transmit BlackOut DMX Packet
DMX_TX.DMX_BlackOut
Else
// Transmit Normal DMX Packet
DMX_TX.DMX_4Channel (DMX_Channels(0),DMX_Channels(1),DMX_Channels(2),DMX_Channels(3))
EndIf
// Strobe Function Set
If strobeOn = 1 Then
resetValue = DMX_Channels(2) // store our dmx channel 3 data
RandGen2.SetRndMax(255) // set MAX random gen value
DMX_Channels(2) = 255 // set our dmx channel 3 to strobe setting
Repeat
DMX_Channels(0) = RandGen2.rand () // Get a random number
DMX_TX.DMX_4Channel (DMX_Channels(0),DMX_Channels(1),DMX_Channels(2),255) 'DMX_4Channel
Until strobeOn = 0
DMX_Channels(2) = resetValue // we need to reset our dmx channel back to the original data
EndIf
beat_delay // decrease beat delay (help stop false beats)
Wend
Code: Select all
Public Sub DMX_4Channel (PanBuffer As Byte, TiltBuffer As Byte, GoboBuffer As Byte, ShutterBuffer As Byte)
Dim EndDmxbuffer As Byte
//=====================================================================================================
// Standard DMX Protocol Break-MAB-StartCode-MTBP
Low (dmxTx) 'set our DMX TX pin low to Initialize the DMX Recievers.
DelayUS(120) 'this is our BREAK
High (dmxTx) 'sets our DMX TX pin high to start the MAB (Mark-After-break)
DelayUS(30) 'usually set around 8us but too short MAB and some receivers will miss the MAB
Low (dmxTx) 'now we LOW our DMX TX pin to start the START CODE Packet
DelayUS(4) '4 microseconds
Low (dmxTx) 'just to make sure our DMX TX pin is low
DelayUS(32) 'this is our Start Code packet
High (dmxTx) '} our two stop bits each 4 microseconds (total 8us)
DelayUS(8) '}
High (dmxTx) 'sets our DMX TX pin high to set the MTBP (MARK TIME BETWEEN PACKETS)
DelayUS(25)
//=====================================================================================================
' channel one PAN
Input(dmxTx)
usart_Writebyte(PanBuffer)
High (dmxTx) 'sets our DMX TX pin high to set the MTBP (MARK TIME BETWEEN PACKETS)
DelayUS(25)
' channel two BARREL
Input(dmxTx)
usart_Writebyte(TiltBuffer)
High (dmxTx) 'sets our DMX TX pin high to set the MTBP (MARK TIME BETWEEN PACKETS)
DelayUS(25)
' channel three COLOURS
Input(dmxTx)
usart_Writebyte(GoboBuffer)
High (dmxTx) 'sets our DMX TX pin high to set the MTBP (MARK TIME BETWEEN PACKETS)
DelayUS(25)
' channel four SHUTTER
Input(dmxTx)
usart_Writebyte(ShutterBuffer)
High (dmxTx) 'sets our DMX TX pin high to set the MTBP (MARK TIME BETWEEN PACKETS)
DelayUS(25)
' make all other channels = 0
EndDmxbuffer = 0
For i = 0 To 59
Input(dmxTx)
usart_Writebyte(EndDmxbuffer)
High (dmxTx) 'sets our DMX TX pin high to set the MTBP (MARK TIME BETWEEN PACKETS)
DelayUS(25)
Next
End Sub
brad wrote: Gotta love programming in swordfish basic!
Just imagine the extra complexity with doing this in assembly!
Users browsing this forum: No registered users and 1 guest