Show Posts
Pages: [1] 2 3 4
1  Using Arduino / General Electronics / Re: Jqf4 solenoid valve, no airflow. Help required on: April 10, 2014, 03:23:15 pm
.I want it to switch at the pwm speed!
Oh, I thought you wanted to use the PWM to reduce the effective voltage because you didn't have access to 3V.

It seems unlikely that you can turn a valve on and off at 500Hz or 1KHz ( depending on which pin you use ) and I am not at all sure why you would want to do such a thing.

Solved. Rather red facedly. For various reasons, not least chinese translation, exaggerad / misleading ebay descriptions and probably some senilty, I thought this unit was a vacuum pump. It isnt. It is just a valve. Doh! And huge embarassment.
All is not lost, since my driver circuit is fine to create that one clunk that closes the valve.

Methinks it would be more useful for what im doing (suction cup vertical wall climber) if it were normally closed, as sucking 100ma to keep it closed is a battery killer... I will find a use for it...I might make an air powered AND gate or something....

Sorry for wasting yr time znd thanks to those who replied.

Anyone know where to find a mini  vacuum pump?.......mind you in my current state of stupidity I may as well reverse the contacts on my mini air pump

2  Using Arduino / General Electronics / Re: Jqf4 solenoid valve, no airflow. Help required on: April 10, 2014, 02:21:53 pm
Try it with DC and a series resistor of about 17 ohms, it could be it is reacting too fast and switching at the PWM frequency.

I dont understand...I want it to switch at the pwm speed! It needs to pulse to be able to pump. Are you saying the pwm is too fast? Thatscsomething I hadnt considered. I will try bit-banging it at varying speeds rather than accepting arduinos pwm speed, and publish the results.

3  Using Arduino / General Electronics / Re: Jqf4 solenoid valve, no airflow. Help required on: April 10, 2014, 02:17:13 pm
How about testing the solenoids at their rated voltage, using a couple of AA cells, before using PWM which they are most probably not designed for.

Because its a pump, operated by a solenoid, and need to be pulsed to make it pump. With a single 3v supply coonected, it goes "clunk" exactly once. Using pwm of 6v @ 50% cycle ..if I understand things correctly ... is the equivalent of giving it 3v, but in pulses. Ifs how I drive a buzzer, which works fine. Same result as youd get if you connevted an aa to speaker..youd get one click, not a continuous tone.
4  Using Arduino / General Electronics / Jqf4 solenoid valve, no airflow. Help required on: April 10, 2014, 12:30:01 pm
I bought some of these:  info shows 3vdc and 115ma

My test rig is as follows. Uno pin 11 with analogWrite value 127 ie im trying to get 50% duty cycle. This goes to base resistor of a 2n222a, emitter to gnd, collector to -ve terminal of device, +ve of device to 5v. The setup is exactly as I would have for buzzer or relay, lazily ommitting flyback diode.

I cant get any airflow in or out of the damn thing. I have varied base resistor, duty cycle, and even used an external psu at 5v, 6v even 9v.

I have measured current through the beast at e.g. 100ma with 6v in @ 50%. This seems to me to be ideal operating point., but no airflow. I even had 175ma through it at 9v with 2.2k base resistor...still nowt.

Other points...I tried 2 or 3 to rule out a dodgy unit. Same results. In all cases mentioned above the unit buzzes (appropriately for the duty cycle if u know what I mean) so it sounds/seems like the thing is working...but it aint! I even dismantled one to see if it had its own oscillator like an active buzzer, but all there is is a magnet and sprung moving coil.its like a tiny loudspeaker in fact minus the cone.

Any ideas?
5  Using Arduino / Programming Questions / Re: Due: SPI speed problem when using 2 interfaces on: March 11, 2014, 06:17:33 am
I might have found the answer...from wikipedia

In practice, cards are rarely ganged together because open-collector operation has problems at high speeds and increases power consumption. Newer versions of the SD specification recommend separate lines to each card

I will try init at a very low speed, then ramp up the clock before subsequent accesses and see how that works.

ps tried the disable first joy
6  Using Arduino / Programming Questions / Due: SPI speed problem when using 2 interfaces on: March 10, 2014, 04:26:17 pm
HW: Due/R3 + 2x identical cheapo ebay SD module with 5v and 3.3v (there is a 3.3 vregulator onboard that presumably drops the 5v)
SW: IDE 1.5.1r2
#include <SPI.h>
#include <SD.h>

I have a very simple SD card cloner set up as follows: MISO,MOSI,SCK on ICSP header, with SS for src drive on 4, SS for dst drive on 10
Before we continue I must make it clear that it works perfectly when I init both SPI channels with SPI_HALF_SPEED, i.e. I have exactly cloned an SD card on this rig. Both ebay cheapo readers running at 5v. So the code and wiring look good, hence not including complete details. I call the src and dst A and B for convenience.

The problem starts when I try SPI_FULL_SPEED, and it gets weird. I have tried the following with 7 different SD or Mini SD cards, ranging from good quality Kingston SDHC 4 through noname 128MB and sizes of 1GB 2GB 4GB. The following issue occurs exactly the same each time, no matter which card I use in A or B:

early code:
#define SRC  4
#define DST  10

Sd2Card src;
Sd2Card dst;

With any/all of the cards in A, with B empty, the following code correctly reports the size:


The same is true for any/all cards in B with A empty::

Also reports correct size

B U T if both A and B are populated, either/both code snippet fail with init returning zero! Remember, at SPI_HALF_SPEED, the amended code reports correctly in all circumstances / permutations

Summary: When both SD readers are populated,BOTH inits fail if they are initialised at full speed, even on two cards that both successfully init'ed at FULL_SPEED when mounted solo, in either reader!

H E L P!!! I want full speed, half speed gives me about 9MB/s which translates to a loooooooong time even for 1GB

Any ideas?

7  Development / Other Software Development / Re: Accessibility - configurable IDE? on: January 17, 2014, 08:24:16 am
many thanks.
8  Using Arduino / Microcontrollers / Re: Arduino Breadboard 8MHz oscillator programming problems on: January 16, 2014, 03:12:17 pm
check the fuses in boards.txt andtry it again. sounds like chip isnt running at 8mhz, causing the timing errorors. if that fails, select standard uno and burn bootlosder to at least get yr chip back
9  Using Arduino / Microcontrollers / Re: Programming ATTiny24 (and 44/84 of course) on: January 16, 2014, 02:23:36 pm
technicaly, the 24 doesnt have or need a bootloader. the ide option to burn bootlosder merely sets the fuses to whatever it finds in boards.txt

make sure your boards.txt is as it was when u programmed ok, select tiny24 1mhz and burn bootloader. alternatively you can manually drive avrdude to reset the fuses to the values in boards.txt then reprogram

if neither work, you may well have a dead chip. one last resort is to use hvsp programming mode to unbrick it, but you will need a hw programmer that can do hvsp, several more wires and an ide that can do hvsp such as atmel studio. I use that with an avr dragon to unbrick tiny24s in hvsp mode.

on the other hand, take the hit and buy a new tiny24 they are only 3 or 4 bucks and thats a way lot less grief.
10  Using Arduino / Microcontrollers / Re: Programming ATTiny24 (and 44/84 of course) on: January 16, 2014, 03:53:34 am
the uno has two different pwm speeds depending on which pins are used...check the arduino docs. the tiny24 cores may do the same. for the future, you can tweak the speed yourself by manipulating low level registers, but thats pretty advanced, and for another day.

im glad your sketch now works and im glad to have been able to help
11  Using Arduino / Programming Questions / Re: "precompiled headers" problem - how to force recompilation? on: January 16, 2014, 03:32:56 am
many thanks. the  library in question is one im writing myself, so I have the chance to try some of these ideas any way I choose. you guys have given me lots to experiment with.
12  Development / Other Software Development / Re: Accessibility - configurable IDE? on: January 15, 2014, 04:56:01 pm
its so unfiriendly i haven't looked to see if i can change window colors...
You can, along with the font itself, and the size.

Any ext6ra assistance, its not clear or obvious to me how to do this
13  Using Arduino / Programming Questions / Re: "precompiled headers" problem - how to force recompilation? on: January 15, 2014, 04:55:20 pm
Presumably you could modify the library code so that you could supply the number (of pins?) as a parameter when the class is initialized?


From my opening post:

What I DONT want to do is have something like:


pinChange pcInstance(NUM_PCINTS);


14  Using Arduino / Microcontrollers / Re: Atmel Studio 6 Device programming issue on: January 15, 2014, 04:53:38 pm
There is a restricted set of tools that studio will work with / recognise. I use an AVR dragon and occasionally an old STK500. The dragon is usb and is recognised fine (but uses special jungo USb drivers which wont work with avrdude/libusb drivers) The STK, being serial (even through serial->usb converter) has to be added manually.

I guess the idea is to make you buy the expensive tools e.g. AVRISPMK2, AVR ONE, JTAG/ICE STK600 etc...haven't heard of anyone using UNO as ISP or cheap eaby usbasp etc. I'd be interesdted to know if anyone has and how etc

below is link to V6 docs which has a table showing all supportedx programmers and MCUs:,d.ZG4
15  Using Arduino / Microcontrollers / Re: Programming ATTiny24 (and 44/84 of course) on: January 15, 2014, 02:57:54 pm
OK. This is from pins_arduino.h under the tiny14 subdirectory:
//                           +-\/-+
//                     VCC  1|    |14  GND
//             (D 10)  PB0  2|    |13  AREF (D  0)
//             (D  9)  PB1  3|    |12  PA1  (D  1)
//                     PB3  4|    |11  PA2  (D  2)
//  PWM  INT0  (D  8)  PB2  5|    |10  PA3  (D  3)
//  PWM        (D  7)  PA7  6|    |9   PA4  (D  4)
//  PWM        (D  6)  PA6  7|    |8   PA5  (D  5)        PWM
The D numbers are the arduino conceptual digital pin numbers, so physical pin 11 on the chip is D2 for example
So,  based on your last:
pin 13 - Photoresistor
pin 10 - Piezo
pin 11 - Led
your code should look like

#define PHOTO 0 // Physical pin 13 = tiny24 pin 0
#define PIEZO 3 // see above
#define LED 2 // same
// later
  pinMode(PIEZO, OUTPUT);
  pinMode(LED, OUTPUT);
  pinMode(PHOTO, INPUT);
// but you really should do this BEFORE calling any pin function e.g. analogRead!!!

The main problem you have though is your analogue writes. analogWrite uses PWM functionality on the pin. From the arduino docs:

"On most Arduino boards (those with the ATmega168 or ATmega328), this function works on pins 3, 5, 6, 9, 10, and 11. On the Arduino Mega, it works on pins 2 - 13 and 44 - 46. Older Arduino boards with an ATmega8 only support analogWrite() on pins 9, 10, and 11. "

Those datasheets will show which pins have PWM functionality. On the tiny24 (see above) its chip pins 5,6,7,8 ie digital pins 5,6,7,8 (altho confusingly not in the same order!)

So, if you have to pulse PIEZO and LED, they need to be on one of those pins. On the UNO through what a poster on here calls "dumb luck"  smiley  10 and 11 support PWM so your sketch works (though you were lucky that calling analogRead before setting the pinmode also happened to work...the chip boots up with pins as inputs!)

#define PIEZO 5
#define LED 6
 should sort that. Next we go back to the doc for analogWrite:


pin: the pin to write to.

value: the duty cycle: between 0 (always off) and 255 (always on).

you say:
    analogWrite(2, 1200);   // turn the LED on (HIGH is the voltage level)
    analogWrite(3, 1000);   // turn the PIEZZO on (HIGH is the voltage level)

I'm not sure why you chose those values, and I dont want to go into 2s-complements maths on 8-bit values, but that code just aint going to do what you think it does. E.g. 1200 is 0x4B0 since you are stuffing into 8 bits, you lose the 4, giving 0xB0 which is 176 if its treated as unsigned, or -80 if its a signed value. Neither of them are close to what you thought you meant!

176/255 = 69% full brightnes (or squeak volume) so (luckily) your dodgy code will actually cause what LOOKS like a flash and a squeak. If all you want to do is turn the LED on or off, use digitalWrite (also consider the tone library for squeaking the buzzer)

To make your code clean, you need to map your value to 0-255 and also say:
for portability and ease of modification / rewiring...all you do if you move a wire is change the #define and the rest of the code "just works" without search and replace of all "2," for e.g. "11," which can change of a lot of wrong stuff accidentally if you arent careful!

A final note, UPPERCASE is usually used for such constants (just a style thing) and analog pins have special names in the pins_arduin.h file, e.g. analog pin 0 is A0.

Using A0 instead of 0 makes your code portable, ie on a UNO, A0 will be mapped to the correct pin for you, and its one less thing to change. if the framework had similar definitions for e.g. PWM pins such as PWM1, PWM2 and digital pins like DIGITAL1, DIGITAL2 etc, we wouldn't be having this conversation at all, as it just would have worked on any variant if you had said:

#define PIEZO PWM1
#define LED DIGITAL1
#define PHOTO A0

.and put the wires in the right holes (aprt from the 1200 vs 255 discussion of course!)

Hope this helps


Pages: [1] 2 3 4