Show Posts
Pages: 1 ... 9 10 [11] 12 13
151  Forum 2005-2010 (read only) / Interfacing / Re: Interfacing with an NTSC TV on: August 28, 2007, 11:29:40 pm
I might have found the bug that makes the uC crash. The loadSprite function. The weird part is it's not even being called. But if I comment it out, the uC runs fine and if I don't it never boots. I've replicated this over many upload cycles. The weird part though is that it still crashes when I compile/upload from the Makefile (0007 and the recently posted 0009)
152  Forum 2005-2010 (read only) / Interfacing / Re: Interfacing with an NTSC TV on: August 28, 2007, 11:45:08 am
I have a Mega168, so yeah 1k worth of RAM. that should be plenty. All I use except the frame buffer are a few int counters for looping (all in functions so they are all released fast). To my calculations, 21x16 would be 336 bytes, which is way under. Now boosting the resolution to just 24x18 (432 bytes... still plenty of room left) and the uC crashes. AS for your idea of packing more pixels per byte, yeah that's a great idea... definitely something I'll look into today.
153  Forum 2005-2010 (read only) / Interfacing / Re: Interfacing with an NTSC TV on: August 27, 2007, 11:10:30 pm
Thanks for the video! that was great. Fixed the issue for real this time.

line 61 is now:
#define      _ntscDelayBackPorch            5.9
and line 64:
#define _ntscDelayVSync                  50

Now why can't I rev up the resolution?... basically anything over 21x16 seems to crash (I don't use the sprite with it, obviously!)
154  Forum 2005-2010 (read only) / Interfacing / Interfacing with an NTSC TV on: August 27, 2007, 07:32:55 pm
Hey guys, this is a follow up on this topic. It started in French, but I figured since NTSC is used mainly in America and in Japan, English might be better suited for the topic. The basic setup is the same as the Arduino pong and the other topic. So this is just my "port" of what these guys did. I did build mine with a "structure" to allow adding pal support to be able to switch modes easily in the code.

Disabling the interrupt timer

I haven't gotten my code to work with cli() and serial so you'll have to modify lib/target/arduino/wiring.c (MAKE A BACKUP) like such:
// enable timer 0 overflow interrupt
#if defined(__AVR_ATmega168__)
    sbi(TIMSK0, TOIE0);
    sbi(TIMSK, TOIE0);

    // enable timer 0 overflow interrupt
#if defined(__AVR_ATmega168__)
    sbi(TIMSK0, TOIE0);
    sbi(TIMSK, TOIE0);

The circuit

That is... Sync to port 8 on the arduino and video to port 9. I use 900 and 300ohm resistors but it should change much anyway; these can be a little off.

Grab the latest version of the code.

Once you've uploaded the code, connect via serial (I use screen in the terminal) and wait for the uC to finish loading (you'll see "Mode:"). If everything went well there should be a dot in the middle of the TV. Now hit enter for usage. If you read through the code you will see there is a way of enabling "signal voltage mode" which allows you to debug your circuit.

There are a few things that are acting weird... I could really use some feedback.
  • If you put the resolution higher the uC seems to crash (not enough ram?).
  • Sometimes the uC acts as if the mode (output) had not been set properly. Re-uploading seemed to have fixed the problem when I've seen it.
  • There may be a timing issue while writing the first few lines. (EDIT: The issue has been fixed, see posts bellow)
  • Going into signal mode sometimes seems to crash the uC (same behavior as the first issue)

I've tested these this with both a mega8 and mega168 (thanks to the USBTiny that appeared in my mailbox this morning and a little magic from its fairy) on the NG and under 0007 and 0009. Optimally this code would need to be ported to a version with interrupt support.

P.S. If that pastie ever goes down, here is a plain text mirror.

And the obligatory picture ^-^

[size=10](The flickering at the top seems to have been fixed – at least as best as I could) FIXED[/size]
155  Forum 2005-2010 (read only) / Interfacing / Re: Arduino PWM on: January 11, 2007, 05:41:40 pm
What you probably want to do is build an H-Bridge circuit.

Here is a fairly simple circuit.

You will need to check if the FETs (IRF*) are rated for this high amperage. They probably are not, make sure you buy some that are rated at least 20% over your peak. You will need to provide PWM from the Arduino on pin 9 to 11 (see the tutorials for this) on the two drive lines. What's great is this will allow you to drive the motor in both direction as well as control speed (with PWM) and break! There is a ton of information on H Bridge on the net, you should easily be able to gather the intel you need. smiley
156  Forum 2005-2010 (read only) / Interfacing / Using a single analog in as a keypad input on: January 30, 2007, 02:02:25 am
Wow I just stumbled on this, you guys have to check this out!


This is just so cool I'm gonna have to quote him right here so you don't have to click the link ;D

This is such a resistor matrix. The columns are connected to ground, in between the column connections are three stacked resistors. The rows are connected via four such stacked resistors to the operating voltage (e.g. 5 V). The AD converter input is blocked by a condensator of 1 nF because the ADC doesn't like high frequencies, that could be caught by the keys, the resistors and the more or less long lines in between all this.
If the key "5" is pressed, a voltage divider gets active:

* 1 k + 820 [ch937] = 1,82k to ground,
* 3,3 k + 680 [ch937] + 180 [ch937] = 4,16k to plus.

At an operating voltage of 5 Volt a divided voltage of

5 * 1,82 / (1,82 + 4,16) = 1,522 Volt

is seen on the AD converter input. If we consider 5% tolerance of the resistors, the resulting voltage is somewhere between 1,468 and 1,627 Volts. The 10-bit AD converter converts this (at 5 V reference voltage) to a value between 300 and 333. If we ignore the lower two bits of the result (e.g. divide the AD result by four or left-adjusting the result - if the ADC provides that function) this yields an 8-bit-value between 74 and 78.
Each key pressed produces a typical voltage range, to be converted to the key code.

Well ok I lied, you will have to check the site to get it all :p

I'm moving soon and have most of my stuff packed or getting ready to so I won't be able to try this for a bit. I just can't wait, this is so ingenious! On top of saving a 12 ports for a direct connection, it saves the very costy 74C922 16 Key encoder ~8$ (iirc) all with a few cents worth of resistors!
157  Forum 2005-2010 (read only) / Interfacing / Re: nRF24L01? on: February 12, 2008, 10:27:56 pm
It's not all that hard, look at the init part and match the parameters to what you can find in the datasheet (speed, MSB/LSB, etc) and then it's just a loop over your data array. But that's for the SPI. I have no idea how your chip works. That's a whole different story. Although that's usually rather straight forward once you get read/write working. Try it out and see what you can come up with. You are welcome to post your code here (or using a pastie) with info about your setup and we'll see what we can do smiley
158  Forum 2005-2010 (read only) / Interfacing / Re: nRF24L01? on: February 12, 2008, 08:39:31 pm
I suggest you have a look at the tutorials.
159  Forum 2005-2010 (read only) / Interfacing / Re: Arduino 3Volts on: February 12, 2008, 03:06:12 am
Doesn't seem like you need the 16Mhz to me. If you're making a custom board I'd say just ditch the crystal and run at 8Mhz, should still be plenty. Hey, at 1MIPS / Mhz it's still faster than the first 386!
160  Forum 2005-2010 (read only) / Interfacing / Re: Arduino 3Volts on: February 12, 2008, 02:37:43 am
For something as mission critical as that, the answer would be no. Otherwise... avr's are know to be very overclockable and 3v is not that far off, it could very well run just fine. Test it! there's no harm. set the jumper to external unplug anything in the power plug and plug your 3v source to the Arduino's 5v and Gnd pin.
161  Forum 2005-2010 (read only) / Interfacing / Re: Arduino 3Volts on: February 12, 2008, 02:25:37 am
So, i don't able to run at 16MHZ with 3V?

It could cause some erratic behaviours. If you can get access to a programmer it would be easy enough to change the fuse (setting) so that the clock is divided by 8. Or use the internal oscillator, but I'm not sure how that behaves when you have an external crystal connected.
162  Forum 2005-2010 (read only) / Interfacing / Re: Communicating with a BQ2013H over HDQ bus on: February 09, 2008, 12:39:19 am
So after quiet some more tinker and digging through the app notes... I present to you the HDQ library smiley-grin (Not that it will be any popular, there are only a handful of HDQ devices ;o)

You can view the source here:

Usage example:


uint8_t r =;

Serial.print("Register 0x1e: ");
Serial.print(" 0x");
Serial.println(r, HEX);

The only other thing needed is to have a string pull up (4.7K did the job, I saw 10K used in the app notes).
163  Forum 2005-2010 (read only) / Interfacing / Communicating with a BQ2013H over HDQ bus on: February 08, 2008, 01:22:31 pm
Hello, I built a circuit which includes a bq2013h battery gas gauge. The IC uses a proprietary communication protocol called HDQ which is very similar to 1-Wire except that it's faster, devices don't send a presence pulse and it transmits words at a time rather than bits at a time. Sadly I had to pick the component with possibly the worst datasheet and app notes TI has ever publish (no, really I mean it!). So I'm having quiet a few issues. A whole word must be sent in a minmum of 190uS, bus is MSB first. As per the datasheet, the slave should pull the line low (there's a 4.7K pull up) once it's received a command register address. But using the code below I never get this ACK from the slave. The only code available anywhere is some weird 8085 asm compiled for a 16CXX PIC and it uses a uart rather than a digital IO.

Two app notes describing the protocol

The first one specifies that "If the host implements the HDQ communication using a discrete processor I/O port, the timing of the transmitted HDQ data and the sampling of the received HDQ data depends on the host processor timing of the transitions on the HDQ line."

Which I interpret as "the slave will copy the host's timing as long as the host respects the min/max timings of the slave". Doesn't seem to be the case. The same app note also says "The procedure is to set the UART baud rate to 57,600 with no parity and 2 stop bits. This yields a data word with 11 bits total (start bit, 8 data bits, and 2 stop bits). At a baud rate of 57,600 (17.3 µs per bit), this is a total communication time of 190.9 µs and meets the required HDQ bit
timing of 190 µs minimum." As such, I've assumed that these minimum timing + a little extra should do just fine and that's what is replicated below.

Sadly this got me nowhere. Got anymore ideas? Anyone? Anyone? Buller?

P.S. I thought HDQ was another brand name for 1-Wire (TWI vs I2C) when I choose the IC, but now it's on the PCB already

uint8_t HDQ::read(uint8_t reg)
      uint8_t result            = 0;
      uint8_t maxTries      = 255;
      uint8_t ii;
      // Compute read mask
      reg |= HDQ_ADDR_MASK_READ;
      sbi(*modeReg, pin);            // Set pin as output
      cbi(*outputReg, pin);      // Bring pin low
      // Wait the minimum break time
      // Bring the pin back high
      cbi(*outputReg, pin);
      for (ii = 0; ii < 8; ii++)
            sbi(*outputReg, pin);
            // Toggle the pin for this bit, MSB first
            if (reg<<ii & B10000000) {
                  sbi(*outputReg, pin);
            else {
                  cbi(*outputReg, pin);
      sbi(*outputReg, pin);
      cbi(*modeReg, pin);      // Set pin as input
      // Wait for the slave to toggle a low
      while (_HDQ_readPin() != 0);
      Serial.println("Got ACK");
      for (ii = 0; ii < 8; ii++)
            result |= _HDQ_readPin()<<(7 - ii);
      return result;
164  Forum 2005-2010 (read only) / Interfacing / High side current reading on: December 21, 2007, 02:37:55 am
Hello, I'm working on an battery powered project that uses the arduino. For purposes of battery monitoring I'd like to be able to read the current on the high side of the circuit. Do you guys have any idea how I can do this using the ADC?

Thanks smiley
165  Forum 2005-2010 (read only) / Interfacing / Re: Arduino breadboard template in SVG & other for on: October 15, 2007, 11:25:46 am
Nice on follower smiley I think the freeduino site has that image available. Keep up the good work!
Pages: 1 ... 9 10 [11] 12 13