Jump to content

Arduino stuff/ programing/so cheap


flyingbrick

Recommended Posts

14 hours ago, Ned said:

why are you still dicking around with this? just buy a speeduino board, and start writing code... those ignition drivers all work etc as well as give you lots of other inputs you're going to need...

or you doing it purely as an exercise on how to drive coils/learn something? I dont understand why you are using a fet to drive an IGBT to drive a coil, when you can just use a fet to drive the coil

Doing it to prove i can.
And i've driven the coils from mosfets many times & burnt up every one of them.

  • Like 1
Link to comment
Share on other sites

  • Replies 416
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

On 13/06/2019 at 22:19, Ned said:

mechanical switches bounce, thats just the nature of them. Add SW debouncing by checking the signal is valid for 30mS or something, or do hardware debouncing with a 100nF capacitor across the switch and a weak pullup? 10k or bigger maybe? i dont usually do HW debouncing as it costs more than a few lines of code so might pay to google a bit....

So I tried adding a resistor to put the pin down to ground but still had triggering issues from the machinery running around it. How does a pull up work?. If I posted the code on here could ya point me in the right direction? Cheers!!!

Link to comment
Share on other sites

4 hours ago, ajg193 said:

Ordered an arduino due off of ali today. Not sure what I will use it for, but the extra speed may outweigh the lack of 5V capability for some applications (32 bit, 84 MHz ARM cpu)

Teensy range is bloody good too, and as the name would suggest, uhhh... teensy. for if you need something with a smaller footprint than the Due.

https://www.pjrc.com/teensy/

Link to comment
Share on other sites

15 hours ago, rusty360 said:

So I tried adding a resistor to put the pin down to ground but still had triggering issues from the machinery running around it. How does a pull up work?. If I posted the code on here could ya point me in the right direction? Cheers!!!

You need to do some of the basic arduino tutorials on this, makes heaps of sense after 

  • Like 1
Link to comment
Share on other sites

  • 3 weeks later...

Should I design up a board to slap an arduino in that has a 12V reg, inputs and will drive ignition / relays / whatever? (Carduino)

 

Also, many of the cheap Chinese arduino clones use the CH340 usb-serial interface chip. Unfortunately the drivers for this are a bit shit. My main desktop was having power/sleep mode troubles, and ended up rebooting everynight (resetting my workspaces, and long running jobs). Tracked it down to a WeMOS board, so all is well if I unplug it last thing. HTH / H4nd

  • Like 2
Link to comment
Share on other sites

On 13/06/2019 at 22:19, Ned said:

mechanical switches bounce, thats just the nature of them. Add SW debouncing by checking the signal is valid for 30mS or something, or do hardware debouncing with a 100nF capacitor across the switch and a weak pullup? 10k or bigger maybe? i dont usually do HW debouncing as it costs more than a few lines of code so might pay to google a bit....

Hi Ned, I've been googling this up a fair bit and cant quite work it out. I'm still getting a large amount of static affecting the pins.

I found this online but cant quite work out the diagram,  I read it as the green line will go to the GPIO pin, both the triangles are to ground?

But this would mean the 3.3v would go straight to ground.

Any help would be awesome! This is the last bit of the puzzle.

Screenshot_20190801-211505_Chrome.jpg

  • Like 1
Link to comment
Share on other sites

hey man. 3v3 does not go directly to ground, it goes to a resistor, which goes to a cap to ground, and to another resistor to ground. It doesnt go directly to ground. You understand what a resistor does right?

thats a pretty simple circuit and should work just fine...? i think i'd prefer it without the 1k resistor myself, so when you press the switch the cap instantly discharges, and keeps the pin low during bouncing while the cap charges? but thats just a feeling without trying any of it myself with a scope to see if that actually works that way.

that way will remove some weird noise and false triggering, and will do a bit for debouncing. It really just slows down the button press, which works as debouncing

  • Like 3
Link to comment
Share on other sites

4 hours ago, Ned said:

hey man. 3v3 does not go directly to ground, it goes to a resistor, which goes to a cap to ground, and to another resistor to ground. It doesnt go directly to ground. You understand what a resistor does right?

thats a pretty simple circuit and should work just fine...? i think i'd prefer it without the 1k resistor myself, so when you press the switch the cap instantly discharges, and keeps the pin low during bouncing while the cap charges? but thats just a feeling without trying any of it myself with a scope to see if that actually works that way.

that way will remove some weird noise and false triggering, and will do a bit for debouncing. It really just slows down the button press, which works as debouncing

Hey ned, yep understand how a resistor reduces the current. I did have the system looking for a pull down but the electrical noise generated from the packing gear just made it trigger like crazy. That's why I thought I would try a pull up.

This is what I have for the wiring circuit. Look ok ?

20190802_144708.jpg

  • Like 1
Link to comment
Share on other sites

Righto so had some success today, I had another look at my circuit and realised I'd farrked up on the bread board. So I got the program running today but the debounce time needed to be set quite high 1500m/s for the program only to register one button push. I'm wondering if this is due to the closing relay being the trigger? Heres a pic of the circult now.

White and grey wires go to the switch (relay) there is a cap in parallel with these. Red is 3.3v. Orange is GPIO pin. Green is ground.

20190805_131532_resized.jpg

20190805_152043_resized.jpg

20190805_152030_resized.jpg

Link to comment
Share on other sites

13 minutes ago, h4nd said:

Good-o, so it's probably staying pulled in, and not oscillating at 100Hz during the transition.

How's the code for reading the pin look?

Yep definitely stays in for very short time based on the led coming on. 

Hold the phone caller I'll try and post the code.

Link to comment
Share on other sites

20 minutes ago, h4nd said:

Good-o, so it's probably staying pulled in, and not oscillating at 100Hz during the transition.

How's the code for reading the pin look?

 

Current Code - 

import constant
import datetime
import RPi.GPIO as GPIO
#
# global variable to count bags processed in current minute
gBagsInMinuteCount = 0
#
# function to realise if bag has been processed
def button_callback(channel):
print("Button was pushed!")
global gBagsInMinuteCount
gBagsInMinuteCount+= 1
#
# write to log file every time the button is pushed
# roll log every day
now = datetime.datetime.now()
logFilename = constant.LOG_DIR + now.strftime("%Y%m%d") + ".log"
#
# write to log file
f = open(logFilename, "a")
f.write(constant.PROCESS_ID + "," + now.strftime("%d/%b/%Y %H:%M:%S") + ",1")
f.close()

#
# main program
# initialise
try:
#
# setup some stuff
GPIO.setwarnings(False) # Ignore warning for now
GPIO.setmode(GPIO.BOARD) # set up BCM GPIO numbering
#
# set pin 7 to be an input
GPIO.setup(7, GPIO.IN)
#
# setup event
GPIO.add_event_detect(7,GPIO.RISING,callback=button_callback,bouncetime=1500)
#
# main loop
currentMinute = datetime.datetime.now().minute
while True:
#
# if have moved to the next minute then update the process status file
now = datetime.datetime.now()
if(now.minute != currentMinute): 
#
# write html file for current count
f = open(constant.HTML_FILE, "w")
f.write("<html>\n")
f.write(" <head>\n")
f.write(" <title>Bag Counter</title>\n")
f.write(" <meta http-equiv='refresh' content='5'>\n")
f.write(" </head>\n")
f.write(" <body>\n")
f.write(" <table style='width:100%'>\n")
f.write(" <tr>\n")
f.write(" <td style='text-align:center; font-size: 4000%'>{}</td>\n".format(gBagsInMinuteCount))
f.write(" </tr>\n")
f.write(" <tr>\n")
f.write(" <td style='text-align:center'><img src='https://www.wilcoxgoodness.co.nz/images/logo@2x.png' alt='wilcox'></td>\n")
f.write(" </tr>\n")
f.write(" <tr>\n")
f.write(" <td style='text-align:center'>updated: " + now.strftime("%Y-%m-%dT %H:%M:%S") + "</td>\n")
f.write(" </tr>\n")
f.write(" </table>\n")
f.write(" </body>\n")
f.write("</html>\n")
f.close()
#
# and reset the counter as is a new minute
gBagsInMinuteCount = 0
currentMinute = now.minute
finally:
#
# clean up
GPIO.cleanup()

 

and help or info would be great as its all very very new to me!
 

 

Link to comment
Share on other sites

Yep i can try. I've learnt that indents and spaces matter for python alright!! Hope that helps, the bit i wasn't 100% sure about is this - GPIO.add_event_detect(7,GPIO.RISING,callback=button_callback,bouncetime=1500)  The whole rising, falling, leading edge, trailing edge confuses me a bit. The bounce time needed to be above 1100 to no register 2 button pushes as one. This is prob to do with the relay holding on for a while. 

Code - 

import constant
import datetime
import RPi.GPIO as GPIO
#
# global variable to count bags processed in current minute
gBagsInMinuteCount = 0
#
# function to realise if bag has been processed
def button_callback(channel):
   print("Button was pushed!")
   global gBagsInMinuteCount
   gBagsInMinuteCount+= 1
   #
   # write to log file every time the button is pushed
   # roll log every day
   now = datetime.datetime.now()
   logFilename = constant.LOG_DIR + now.strftime("%Y%m%d") + ".log"
   #
   # write to log file
   f = open(logFilename, "a")
   f.write(constant.PROCESS_ID + "," + now.strftime("%d/%b/%Y %H:%M:%S") + ",1")
   f.close()
   
#
# main program
# initialise
try:
   #
   # setup some stuff
   GPIO.setwarnings(False) # Ignore warning for now
   GPIO.setmode(GPIO.BOARD)  # set up BCM GPIO numbering
   #
   # set pin 7 to be an input
   GPIO.setup(7, GPIO.IN)
   #
   # setup event
   GPIO.add_event_detect(7,GPIO.RISING,callback=button_callback,bouncetime=1500)
   #
   # main loop
   currentMinute = datetime.datetime.now().minute
   while True:
      #
      # if have moved to the next minute then update the process status file
      now = datetime.datetime.now()
      if(now.minute != currentMinute):       
         #
         # write html file for current count
         f = open(constant.HTML_FILE, "w")
         f.write("<html>\n")
         f.write("  <head>\n")
         f.write("  <title>Bag Counter</title>\n")
         f.write("    <meta http-equiv='refresh' content='5'>\n")
         f.write("  </head>\n")
         f.write("  <body>\n")
         f.write("    <table style='width:100%'>\n")
         f.write("      <tr>\n")
         f.write("        <td style='text-align:center; font-size: 4000%'>{}</td>\n".format(gBagsInMinuteCount))
         f.write("      </tr>\n")
         f.write("      <tr>\n")
         f.write("        <td style='text-align:center'><img src='https://www.wilcoxgoodness.co.nz/images/logo@2x.png' alt='wilcox'></td>\n")
         f.write("      </tr>\n")
         f.write("      <tr>\n")
         f.write("        <td style='text-align:center'>updated: " + now.strftime("%Y-%m-%dT %H:%M:%S") + "</td>\n")
         f.write("      </tr>\n")
         f.write("    </table>\n")
         f.write("  </body>\n")
         f.write("</html>\n")
         f.close()
         #
         # and reset the counter as is a new minute
         gBagsInMinuteCount = 0
         currentMinute = now.minute
finally:
   #
   # clean up
   GPIO.cleanup()

 

  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...