Welcome
Username or Email:

Password:


Missing Code




[ ]
[ ]
Online
  • Guests: 84
  • Members: 0
  • Newest Member: omjtest
  • Most ever online: 396
    Guests: 396, Members: 0 on 12 Jan : 12:51
Members Birthdays:
All today's birthdays', congrats!
Ian (36)
Lucas (39)


Next birthdays
01/31 Mathias (41)
01/31 slash128v6 (52)
02/01 Barry (70)
Contact
If you need assistance, please send an email to forum at 4hv dot org. To ensure your email is not marked as spam, please include the phrase "4hv help" in the subject line. You can also find assistance via IRC, at irc.shadowworld.net, room #hvcomm.
Support 4hv.org!
Donate:
4hv.org is hosted on a dedicated server. Unfortunately, this server costs and we rely on the help of site members to keep 4hv.org running. Please consider donating. We will place your name on the thanks list and you'll be helping to keep 4hv.org alive and free for everyone. Members whose names appear in red bold have donated recently. Green bold denotes those who have recently donated to keep the server carbon neutral.


Special Thanks To:
  • Aaron Holmes
  • Aaron Wheeler
  • Adam Horden
  • Alan Scrimgeour
  • Andre
  • Andrew Haynes
  • Anonymous000
  • asabase
  • Austin Weil
  • barney
  • Barry
  • Bert Hickman
  • Bill Kukowski
  • Blitzorn
  • Brandon Paradelas
  • Bruce Bowling
  • BubeeMike
  • Byong Park
  • Cesiumsponge
  • Chris F.
  • Chris Hooper
  • Corey Worthington
  • Derek Woodroffe
  • Dalus
  • Dan Strother
  • Daniel Davis
  • Daniel Uhrenholt
  • datasheetarchive
  • Dave Billington
  • Dave Marshall
  • David F.
  • Dennis Rogers
  • drelectrix
  • Dr. John Gudenas
  • Dr. Spark
  • E.TexasTesla
  • eastvoltresearch
  • Eirik Taylor
  • Erik Dyakov
  • Erlend^SE
  • Finn Hammer
  • Firebug24k
  • GalliumMan
  • Gary Peterson
  • George Slade
  • GhostNull
  • Gordon Mcknight
  • Graham Armitage
  • Grant
  • GreySoul
  • Henry H
  • IamSmooth
  • In memory of Leo Powning
  • Jacob Cash
  • James Howells
  • James Pawson
  • Jeff Greenfield
  • Jeff Thomas
  • Jesse Frost
  • Jim Mitchell
  • jlr134
  • Joe Mastroianni
  • John Forcina
  • John Oberg
  • John Willcutt
  • Jon Newcomb
  • klugesmith
  • Leslie Wright
  • Lutz Hoffman
  • Mads Barnkob
  • Martin King
  • Mats Karlsson
  • Matt Gibson
  • Matthew Guidry
  • mbd
  • Michael D'Angelo
  • Mikkel
  • mileswaldron
  • mister_rf
  • Neil Foster
  • Nick de Smith
  • Nick Soroka
  • nicklenorp
  • Nik
  • Norman Stanley
  • Patrick Coleman
  • Paul Brodie
  • Paul Jordan
  • Paul Montgomery
  • Ped
  • Peter Krogen
  • Peter Terren
  • PhilGood
  • Richard Feldman
  • Robert Bush
  • Royce Bailey
  • Scott Fusare
  • Scott Newman
  • smiffy
  • Stella
  • Steven Busic
  • Steve Conner
  • Steve Jones
  • Steve Ward
  • Sulaiman
  • Thomas Coyle
  • Thomas A. Wallace
  • Thomas W
  • Timo
  • Torch
  • Ulf Jonsson
  • vasil
  • Vaxian
  • vladi mazzilli
  • wastehl
  • Weston
  • William Kim
  • William N.
  • William Stehl
  • Wesley Venis
The aforementioned have contributed financially to the continuing triumph of 4hv.org. They are deserving of my most heartfelt thanks.
Forums
4hv.org :: Forums :: Computer Science
« Previous topic | Next topic »   

a PIC based capacitor charger

Move Thread LAN_403
Bjørn
Sun Aug 12 2007, 04:09AM
Bjørn Registered Member #27 Joined: Fri Feb 03 2006, 02:20AM
Location: Hyperborea
Posts: 2058
The master generates the clock. Hardware SPI has a programmable clock divider so you can select the speed over a wide range.

Make sure you think about what will happen if noise makes you miss a clock cycle or trigger a fake one.
Back to top
...
Sun Aug 12 2007, 05:01AM
... Registered Member #56 Joined: Thu Feb 09 2006, 05:02AM
Location: Southern Califorina, USA
Posts: 2445
One thing to keep in mind when using normal photodiodes for comunication is that they are extreemly slow, I usually wouldn't use them at >100khz...
Also, I tend to aviod the pic18fxxx3 series, as microchips C compiler doesn't support any of the chips with 12 bit a/d (denoted by the 3 at the end). So if you ever get sick of assembler and decide to go for C (there is enogh power in them 18f25xx series to do a lot of stuff ) you are stuck. In my GPS tracker I am using a pic18f2550 and an external a/d chip, (the MCP3421is an 18bit serial adc that is in a tiny 6pin package, and costs under $2). Also, if you go that route you can connect the dac directly to the internal i2c hardware of the chip (remembering to set the BRGH register nice and low, 10khz should be more than enough), which also frees up the RX pin for the hardware EAUSART (usefull if you ever want to give it a async interface (ie, rs232) to a computer or something).

BTW, when using SPI, keep in mind that you are suppose to be always transfering data in both directions whevever there is a clock (even if it is just garbage data, like all 0's). And IIRC, the slowest I2C divider is 1/64, which will give you a resonably slow clock. (250khz) If thst is still to fast, is is pretty easy to 'bit bang' a SPI-ish serial interface to transfer data between the chips. You would just disable the internal hardware module and have code that looks for the line to go low, then cycles the clock, sends a bit, cycle the clock, etc.
Back to top
Thomas
Sun Aug 12 2007, 05:14AM
Thomas Registered Member #120 Joined: Fri Feb 10 2006, 07:07AM
Location: Westchester New York
Posts: 83
Wait i'm sorry, but in a master slave setup the clock is only in one direction, right? Also since I just discovered that i can change the frequency I will run my serial interface at 50kHz, I don't think i will have a problem. I just wanted to confirm the direction of data. I got everything else working, just not the serial part. Other then that I have to code a 12 bit to 4 bcd digits for output.
I just want to solve this little issue before i order my boards.
Back to top
Bjørn
Sun Aug 12 2007, 07:17AM
Bjørn Registered Member #27 Joined: Fri Feb 03 2006, 02:20AM
Location: Hyperborea
Posts: 2058
The clock always goes from master to slave, the data goes in both directions at the same time. Check the datasheet to find out what the largest divider is.

SPI ports can be used for many things, I just made a 15 MHz frequency counter with one and 10 lines of code.
Back to top

Moderator(s): Chris Russell, Noelle, Alex, Tesladownunder, Dave Marshall, Dave Billington, Bjørn, Steve Conner, Wolfram, Kizmo, Mads Barnkob

Go to:

Powered by e107 Forum System
 
Legal Information
This site is powered by e107, which is released under the GNU GPL License. All work on this site, except where otherwise noted, is licensed under a Creative Commons Attribution-ShareAlike 2.5 License. By submitting any information to this site, you agree that anything submitted will be so licensed. Please read our Disclaimer and Policies page for information on your rights and responsibilities regarding this site.