Show Posts
Pages: 1 2 [3] 4 5 ... 442
31  Using Arduino / Displays / Re: Graphical LCD (ST7920 Driver) - a warning and a question on: May 15, 2014, 03:05:30 am
So your LCD already includes a series resistor for the backlight (the 33 ohms that you measured). It also has the contrast adjustment pot built-in. You are probably right about JP2, you can either solder a jumper there or you can connect the PSB pin on the edge connector to +5V or ground to select serial or parallel mode. But I suggest you trace that wire from the jumper middle pad to the PSB pin on the edge connector, to make sure that it isn't already connected to +5V or ground through a 0 ohm resistor, as was reported by someone else using a similar GLCD recently.

EDIT: I can't see any 0 ohm resistors in that photo, so I think you are safe.
32  Using Arduino / Project Guidance / Re: Measure of frequency on: May 04, 2014, 06:01:42 pm
Depending on the range of frequencies you want to measure, this one that I use may do the job.
33  Using Arduino / Project Guidance / Re: Anyone have a 3d printer? on: May 04, 2014, 05:54:14 pm
I have a RepRapPro Ormerod, which is sold in kit form by RS Components for just under £500 (+VAT where applicable). I'm fairly happy with it, although I have made major changes to the firmware (btw the electronics is based on the Arduino Due), replaced a few acrylic and MDF parts by aluminium, and replaced the original unmodulated IR height sensor by a combined modulated IR + ultrasonic one (and I have sold around 50 of these to other Ormerod users).

Printing large parts with a 3D printer is slow, and therefore expensive in machine time. 3D printers are great for prototyping and for small production runs, but for a large production run (hundreds or thousands of copies), you will want to use injection moulding.
34  Using Arduino / Microcontrollers / Re: Attiny 45 38khz flash on: April 11, 2014, 04:50:45 pm
Analog pin 4 does not support PWM, so you can't use the hardware timer/counters to generate a signal on that pin directly.
35  Using Arduino / Sensors / Re: Ultrasonic Parking Sensor Help on: March 11, 2014, 08:04:37 pm
For 1m range I think a ping sensor such as HC-SR04 would probably be sufficient and much easier than what I am doing. My application is really an ultrasonic modem. I was only bouncing the signal off the ceiling because that was a convenient way of testing it.
36  Using Arduino / Microcontrollers / Re: Bot Interrupt Pins quit working. on: March 11, 2014, 07:46:00 pm
polling is not really energy efficient, you're doing stuff that can be done in hardware with software.

There is nothing at all wrong with doing in software what can be done in hardware, that is what microcontrollers are all about. If the mcu is running at full power anyway then energy efficiency doesn't come into it. I've already said that I use an interrupt where I want to wake up the mcu from power down mode.
37  Using Arduino / Microcontrollers / Re: Bot Interrupt Pins quit working. on: March 11, 2014, 03:41:48 am
I think it's a bad idea to detach/attach interrupts inside the ISR. You won't get nested interrupts anyway unless you re-enable interrupts inside the ISR, and doing that is best avoided. A more professional solution to the problem you are trying to solve is to use an edge-triggered interrupt (i.e. mode FALLING instead of LOW), and to record the time at which the interrupt occurred. You can do this by calling micros() within the ISR and storing the returned value. Then in the ISR you can do nothing if not enough time has elapsed since the last interrupt. I agree that in simple systems with very little else going on (e.g. no serial I/O), calling delayMicroseconds inside the ISR may be an inelegant but simple way of debouncing.

However, it is generally simpler to handle pushbuttons by polling, except in the case where the button is used to wake up the mcu from power down mode. In that case, I use the interrupt only to wake up the mcu, and poll it the rest of the time.
38  Using Arduino / Sensors / Re: TCRT1000 sensor... i really need help. on: March 08, 2014, 02:36:22 pm
plz help me the circuit posted by the guy is not lot of noise  smiley-lol

That is nowhere near enough information. What is your application, what is the material that you are reflecting the IR from, and what is the distance between the TCRT1000 and the material you are trying to detect?

The schematic published earlier in this thread is suitable for detecting at quite long distances, but only if the system is well-shielded from sunlight and incandescent artificial light (otherwise the detector will saturate). For detection at shorter ranges, ditch the op amp, reduce the detector load resistor to about 3K3, and feed the detector output directly into an ADC pin.
39  Using Arduino / Microcontrollers / Re: Attiny 45 38khz flash on: February 20, 2014, 04:29:03 am
In case it helps, here is code I am using to turn 3 devices on or off when a button is pressed. I build it in AVR Studio, so it doesn't use the Arduino libraries (although I borrowed some code from them), and I use the internal 8MHz oscillator.

 * RemoteControl.cpp
 * Created: 25/11/2012 12:41:35
 *  Author: David

#include <avr/io.h>
#include <avr/interrupt.h>
#include <avr/sleep.h>

#define F_CPU (8000000UL) // 8MHz

// Class to hold the data for the IR on/off signal for a particular device
class RemoteData
uint16_t headerMarkLength;
uint16_t headerNormalLength;
uint16_t headerRepLength;
uint16_t frequency;
uint16_t bitLength;
uint16_t bitPeriod;
uint32_t burstPeriod;
uint8_t numRepeats;
uint8_t numCycles;
const uint8_t *normalData;
const uint8_t *repeatData;

void generateBurst(bool isRepeat) const;

RemoteData(uint16_t hml, uint16_t hnl, uint16_t hrl, uint16_t f, uint16_t bl, uint16_t bp, uint32_t up,
uint8_t nr, uint8_t nc, const uint8_t* nd, const uint8_t* rd)
: headerMarkLength(hml), headerNormalLength(hnl), headerRepLength(hrl), frequency(f), bitLength(bl), bitPeriod(bp), burstPeriod(up),
numRepeats(nr), numCycles(nc), normalData(nd), repeatData(rd)
{ }

void activate() const;

// Data for PVR on/off signal
const uint8_t pvrNormalData[] = {0b11111111, 0b11111011, 0b11111111, 0b11010101, 0b01010101, 0b01000000, 0};
const uint8_t pvrRepeatData[] = {0b10000000, 0};

const RemoteData pvr(9000, 13500, 11100, 38000, 555, 1110, 108000UL, 2, 1, pvrNormalData, pvrRepeatData);

// Data for TV on/off signal
const uint8_t tvNormalData[] = {0b10111111, 0b01011011, 0b11011000, 0};
const uint8_t tvRepeatData[] = {0b10111110, 0b01110110, 0b10101101, 0};

const RemoteData tv(0, 0, 0, 38000, 250, 1060, 66200UL, 1, 3, tvNormalData, tvRepeatData);

// Data for hifi on/off signal
const uint8_t hifiNormalData[] = {0b11110111, 0b01111111, 0b01010110, 0b10110101, 0b01010101, 0b11011111, 0b10101101, 0b01010101, 0};
const uint8_t hifiRepeatData[] = {0b10000000, 0};

const RemoteData hifi(9000, 13500, 13500, 38000, 555, 1120, 108000UL, 2, 1, hifiNormalData, hifiRepeatData);

// Set the frequency that we will get on pin OCR1A but don't turn it on
void setFrequency(uint16_t freq)
  uint32_t requiredDivisor = (F_CPU/2)/(uint32_t)freq;

  uint16_t prescalerVal = 1;
  uint8_t prescalerBits = 1;
  while ((requiredDivisor + prescalerVal/2)/prescalerVal > 256)
    prescalerVal <<= 1;
  uint8_t top = ((requiredDivisor + (prescalerVal/2))/prescalerVal) - 1;
  TCCR1 = (1 << CTC1) | prescalerBits;
  GTCCR = 0;
  OCR1C = top;

// Turn the frequency on
void on()
  TCNT1 = 0;
  TCCR1 |= (1 << COM1A0);

// Turn the frequency off and turn off the IR LED.
// We let the counter continue running, we just turn off the OCR1A pin.
void off()
  TCCR1 &= ~(1 << COM1A0);

volatile uint32_t timer0_overflow_count = 0; // microseconds timer

// ISR for timer 0, counts microseconds
//TIFR |= _BV(TOV0);

// ISR for INT0, wakes up from sleep mode when button is pressed
GIMSK = 0; // disable INT0

// Return the number of microseconds from start
uint32_t micros()
uint8_t oldSREG = SREG;
uint32_t m = timer0_overflow_count;
uint8_t t = TCNT0;

if ((TIFR & (1 << TOV0)) && (t < 255))

return (m << 8) | t;

void RemoteData::generateBurst(bool repeat) const
  uint32_t start = micros();
  if (headerMarkLength != 0)
    while (micros() - start < headerMarkLength) {}
    uint32_t headerLength = repeat ? headerRepLength : headerNormalLength;
    while (micros() - start < headerLength) {}

  const uint8_t* p = (repeat ? repeatData : normalData);
  uint32_t bitStart = micros();
    uint8_t b = *p++;
    if (b == 0) break;
    for (uint8_t i = 0; i < 8; ++i)
      if (b & 0x80)
        while (micros() - bitStart < bitLength) {}
      while (micros() - bitStart < bitPeriod) {}
      b <<= 1;
      bitStart += bitPeriod;
  while (micros() - start < burstPeriod) {};

void RemoteData::activate() const
  for (uint8_t c = 0; c < numCycles; ++c)
    for (uint8_t i = 0; i < numRepeats; ++i)

void setup()
PORTB = 0b00011100; // pullup resistor on PB2/3/4 enabled, outputs PB0 and PB1 low
DDRB =  0b00000011; // PB0 and PB1 are outputs, rest are inputs

TCCR0A = 0;
TCCR0B = _BV(CS01); // prescaler = 8 so 1MHz count rate

TIMSK = _BV(TOIE0); // enable timer 0 overflow interrupt
GIMSK = 0;
PCMSK = 0;

int main(void)
for (uint8_t i = 0; i < 6; ++i)
uint32_t start = micros();
PORTB ^= 0b00000001; // toggle visible LED
while (micros() - start < 250000UL) {} // wait 0.25 secs before toggling it again

    for (;;)
// Wait for button to be pressed
if (PINB & 0b00000100)
uint32_t now = micros();
while ((micros() - now) < 5000) {}
} while (PINB & 0b00000100);

PORTB |= 0b00000001; // turn on visible LED
uint32_t start = micros();

// The TV doesn't always respond to the PVR HDMI signal up unless we activate it a short while before the PVR. So start the TV first and PVR last.
while (micros() - start < 250000UL) {} // wait until 200ms after we started
while (micros() - start < 500000UL) {} // wait until 500ms after we started

while (micros() - start < 1000000UL) {} // keep LED on for at least a second

PORTB &= 0b11111110; // turn LED off

// Wait for button to be released
start = micros();
for (;;)
uint32_t now = micros();
if (!(PINB & 0b00000100))
start = now;
else if (now - start >= 5000)
40  Using Arduino / General Electronics / Re: NPN transistor switching on: February 20, 2014, 03:03:08 am
Glad you got it working. It sounds to me that the output driver on that pin has failed and only the internal pullup resistor is working (just as if you hadn't made the pinMode call).
41  Using Arduino / Microcontrollers / Re: Attiny 45 38khz flash on: February 20, 2014, 03:01:11 am
So have you programmed the fuses in the attiny to use the external crystal and clear the CLKDIV8 fuse?

I normally use the 8MHz internal clock on the attiny. The frequency doesn't need to be precise for 38kHz IR.
42  Using Arduino / General Electronics / Re: NPN transistor switching on: February 19, 2014, 03:53:38 pm
On that faulty channel:

1. Check that the 1K base resistor really is 1k and you have not inadvertently used a higher value. Similarly for the 150 ohm resistor in series with the LED.

2. Check that you have made a call to set the pinMode of the pin driving the TIP122 to OUTPUT.

3. Check that when the LED is switched on by the TIP122, the TIP122 emitter is at 0V in case you have a bad or missing ground connection..
43  Using Arduino / Microcontrollers / Re: Attiny 45 38khz flash on: February 19, 2014, 03:32:32 pm
What clock frequency are running the attiny45 at? Did you set F_CPU in the board definition entry to match that frequency? If you are using the internal 8MHz clock, did you clear the CLKDIV8 fuse in the attiny?
44  Using Arduino / Motors, Mechanics, and Power / Re: High level switching with PNP darlington on: February 11, 2014, 05:07:53 pm
1. Halogen lamps take much more current for a short while when you first turn them on. That is temporarily overloading your power supply.

2.You may have difficulty keeping your TIP125s cool enough if you put 5A through them, even with the heatsinks. Mosfets would normally be used for this application, because they dissipate much less power when switching high currents, so if chosen carefully they would not need heatsinks at all.
45  Using Arduino / General Electronics / Re: Reverse polarity protection: P channel or N channel MOSFET ? on: February 10, 2014, 03:23:46 am
You can use that circuit without the resistor and zener diode if you can guarantee that there will never be transients on the 12V input that take it higher than the Vgs rating of the mosfet (20V for the one you have chosen).

The mosfet you have chosen is IMO not suitable for 3A load current because it is likely to overheat at that current. You need a mosfet with either lower Rds(on), or higher heat dissipation capacity (for which you will need a mosfet in a larger case style such as SOT223). Or two of those in parallel.
Pages: 1 2 [3] 4 5 ... 442