Author Topic: While used for time.  (Read 2608 times)

0 Members and 1 Guest are viewing this topic.

Offline dannytemmermanTopic starter

  • Full Member
  • ***
  • Posts: 48
  • Helpful? 0
While used for time.
« on: February 10, 2009, 11:42:19 AM »
I want to let an action to happen for 1 second.

I want it to read the frequency of a signal during 1 second.


Please can anyone help me with this cause I already searched this forum and I can't find anything about this.

Offline galannthegreat

  • Supreme Robot
  • *****
  • Posts: 615
  • Helpful? 4
  • Blue-Lensed Blue LEDs?! What?! Impossible!!
Re: While used for time.
« Reply #1 on: February 10, 2009, 12:28:52 PM »
set your output high, delay for 1 second or 1000 ms, set output low, this is the easiest way to do this.

say i do this on my PIC in CCS C:

while(1)
{
 output_high(PIN_D0) //I'm simply selecting the pin to use here and setting it high
 delay_ms(1000) //1000 ms delay, or 1 second
 output_low(PIN_D0)
}

This is a very basic set up of a loop

also take a look at the servo page on the SoR site it helps out abit too.
Kurt

Offline chelmi

  • Supreme Robot
  • *****
  • Posts: 496
  • Helpful? 15
Re: While used for time.
« Reply #2 on: February 10, 2009, 01:03:42 PM »
set your output high, delay for 1 second or 1000 ms, set output low, this is the easiest way to do this.

say i do this on my PIC in CCS C:

while(1)
{
 output_high(PIN_D0) //I'm simply selecting the pin to use here and setting it high
 delay_ms(1000) //1000 ms delay, or 1 second
 output_low(PIN_D0)
}

This is a very basic set up of a loop

also take a look at the servo page on the SoR site it helps out abit too.

I think the op was asking to *read* the frequency of a signal, not generate one. And by the way, you code won't work. Since there is no delay at the end of the while loop, the signal will go high only a few cycle after it went low.

Regarding the original request, I'd use a counter (see your MCU datasheet for more details).
Something like this:

initialize_counter();
wait_millis(1000);
freq = read_counter();

I'm not sure why you want to use a while loop here.

Chelmi.

Offline pomprocker

  • Supreme Robot
  • *****
  • Posts: 1,430
  • Helpful? 16
  • Sorry miss, I was giving myself an oil-job.
Re: While used for time.
« Reply #3 on: February 10, 2009, 02:21:19 PM »
If this is for capturing your IR remote pulses, I don't understand why you don't want to build that IR widget, it is really easy. There is also the IR Decoder schematic on that knowledge base I showed you!

Offline dannytemmermanTopic starter

  • Full Member
  • ***
  • Posts: 48
  • Helpful? 0
Re: While used for time.
« Reply #4 on: February 11, 2009, 06:55:19 AM »
If this is for capturing your IR remote pulses, I don't understand why you don't want to build that IR widget, it is really easy. There is also the IR Decoder schematic on that knowledge base I showed you!

Do you need to program an IC to make the IR widget work?
I want to make the USB version then.
« Last Edit: February 11, 2009, 06:57:50 AM by dannytemmerman »

Offline pomprocker

  • Supreme Robot
  • *****
  • Posts: 1,430
  • Helpful? 16
  • Sorry miss, I was giving myself an oil-job.
Re: While used for time.
« Reply #5 on: February 11, 2009, 10:43:06 AM »
Do you need to program an IC to make the IR widget work?
I want to make the USB version then.


Yes they use a PIC, but if you're good you can do it with any IC. You will also need something like a ft232rl or cp2103 breakout from sparkfun.com for the USB connection to the IC. Then you can just do it all on a breadboard with the minimal configuration using that Fairchild QSE157 IR detector.

Once you get the data into your computer you use that free IR scope software to read the data. From there you can visually see what the pulse looks like.

Offline dannytemmermanTopic starter

  • Full Member
  • ***
  • Posts: 48
  • Helpful? 0
Re: While used for time.
« Reply #6 on: February 11, 2009, 11:05:00 AM »
Do you need to program an IC to make the IR widget work?
I want to make the USB version then.


Yes they use a PIC, but if you're good you can do it with any IC. You will also need something like a ft232rl or cp2103 breakout from sparkfun.com for the USB connection to the IC. Then you can just do it all on a breadboard with the minimal configuration using that Fairchild QSE157 IR detector.

Once you get the data into your computer you use that free IR scope software to read the data. From there you can visually see what the pulse looks like.

Is the PIC used to convert the  usb signal?
Or what?
I don't now that much about IC?

Offline pomprocker

  • Supreme Robot
  • *****
  • Posts: 1,430
  • Helpful? 16
  • Sorry miss, I was giving myself an oil-job.
Re: While used for time.
« Reply #7 on: February 11, 2009, 11:14:02 AM »
From the link:


The IR Widget solves these problems by using a microcontroller to process the IR signal without interruption and send the data to the PC using ordinary asynchronous serial transmission. This allows the OS to service the serial port with standard drivers and allows the use of USB to serial converters. Simple circuits built with 74HC series parts can also be used. The data is sent in real time and is in a format that allows reasonably precise reconstruction of the actual IR signal received.


The code for the IC is linked at the bottom of the page, He also mentions using simple logic ICs '74HC' series in another version of the schematic.

http://www.compendiumarcana.com/irwidget/

Offline dannytemmermanTopic starter

  • Full Member
  • ***
  • Posts: 48
  • Helpful? 0
Re: While used for time.
« Reply #8 on: February 11, 2009, 11:26:36 AM »
From the link:


The IR Widget solves these problems by using a microcontroller to process the IR signal without interruption and send the data to the PC using ordinary asynchronous serial transmission. This allows the OS to service the serial port with standard drivers and allows the use of USB to serial converters. Simple circuits built with 74HC series parts can also be used. The data is sent in real time and is in a format that allows reasonably precise reconstruction of the actual IR signal received.


The code for the IC is linked at the bottom of the page, He also mentions using simple logic ICs '74HC' series in another version of the schematic.

http://www.compendiumarcana.com/irwidget/


So the parts that I need to buy to make this are:
an IR detector module
an usb male port
an ft232r
and an pic12f629
Is this correct?
And what is L1 in he schematic?


Can I program the PIC directly from USB?
« Last Edit: February 11, 2009, 11:48:26 AM by dannytemmerman »

Offline pomprocker

  • Supreme Robot
  • *****
  • Posts: 1,430
  • Helpful? 16
  • Sorry miss, I was giving myself an oil-job.
Re: While used for time.
« Reply #9 on: February 11, 2009, 12:10:41 PM »
Follow this schematic:

http://www.compendiumarcana.com/irwidget/usb_simple.png


L1 is usually a ferrite bead, but trust me and buy a breakout board and you won't need to do all that.

Parts list
http://www.sparkfun.com/commerce/product_info.php?products_id=718
http://www.sparkfun.com/commerce/product_info.php?products_id=8375   (get a handful, you use these like candy in electronics)
http://www.sparkfun.com/commerce/product_info.php?products_id=533
http://www.sparkfun.com/commerce/product_info.php?products_id=8377
http://octopart.com/info/Fairchild/QSE157
http://www.sparkfun.com/commerce/product_info.php?products_id=112
http://www.sparkfun.com/commerce/product_info.php?products_id=8023 (hookup wire for breadboarding)

and i've never used PICs because I heard their development environment isn't fee whereas all the tools to program an AVR are free.

I would try to do it with this (but the code would need to be modified a bit):

http://www.sparkfun.com/commerce/product_info.php?products_id=211

otherwise here is your PIC:

http://octopart.com/case+%2F+package--DIP-8/search?q=pic12f629


EDIT: MCU's need to be programmed using either a special programmer or via a serial port. You can check their respective datasheets.

PS. If you want to wait a bit, I plan on making one of these within the next couple weeks, and I could write up a tutorial.
« Last Edit: February 11, 2009, 12:12:36 PM by pomprocker »

Offline dannytemmermanTopic starter

  • Full Member
  • ***
  • Posts: 48
  • Helpful? 0
Re: While used for time.
« Reply #10 on: February 11, 2009, 12:35:33 PM »
Follow this schematic:

http://www.compendiumarcana.com/irwidget/usb_simple.png


L1 is usually a ferrite bead, but trust me and buy a breakout board and you won't need to do all that.

Parts list
http://www.sparkfun.com/commerce/product_info.php?products_id=718
http://www.sparkfun.com/commerce/product_info.php?products_id=8375   (get a handful, you use these like candy in electronics)
http://www.sparkfun.com/commerce/product_info.php?products_id=533
http://www.sparkfun.com/commerce/product_info.php?products_id=8377
http://octopart.com/info/Fairchild/QSE157
http://www.sparkfun.com/commerce/product_info.php?products_id=112
http://www.sparkfun.com/commerce/product_info.php?products_id=8023 (hookup wire for breadboarding)

and i've never used PICs because I heard their development environment isn't fee whereas all the tools to program an AVR are free.

I would try to do it with this (but the code would need to be modified a bit):

http://www.sparkfun.com/commerce/product_info.php?products_id=211

otherwise here is your PIC:

http://octopart.com/case+%2F+package--DIP-8/search?q=pic12f629


EDIT: MCU's need to be programmed using either a special programmer or via a serial port. You can check their respective datasheets.

PS. If you want to wait a bit, I plan on making one of these within the next couple weeks, and I could write up a tutorial.



Okay

Thanks

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,658
  • Helpful? 169
    • Society of Robots

Offline pomprocker

  • Supreme Robot
  • *****
  • Posts: 1,430
  • Helpful? 16
  • Sorry miss, I was giving myself an oil-job.
Re: While used for time.
« Reply #12 on: February 13, 2009, 11:00:13 AM »
I looked more at that IR widget, and I got all the parts to make the simplified USB version, but I looked at the code and its written in ASM for the PIC. I was hoping it was going to be in C so I could easily translate it into C for the ATmega.

Offline dannytemmermanTopic starter

  • Full Member
  • ***
  • Posts: 48
  • Helpful? 0
Re: While used for time.
« Reply #13 on: February 13, 2009, 11:06:08 AM »
I looked more at that IR widget, and I got all the parts to make the simplified USB version, but I looked at the code and its written in ASM for the PIC. I was hoping it was going to be in C so I could easily translate it into C for the ATmega.

i have found a website for my remote (http://www.sbprojects.com/knowledge/ir/rcmm.htm)but now I don't now how to let my IC recognise it.
Do you now the code to recognise it?


Thanks
« Last Edit: February 15, 2009, 02:16:33 AM by dannytemmerman »

 


Get Your Ad Here