12F683 - basic code not working


Closed Thread
Results 1 to 40 of 57

Hybrid View

  1. #1
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,605


    Did you find this post helpful? Yes | No

    Default Re: 12F683 - basic code not working

    Hi,
    Glad you've got it going! Just a quick note: The I2CREAD/I2CWRITE commands does not use the (M)SSP module in the PIC. You're enabling the (M)SSP module for I2C mode so I'm actually a bit surprised that it works because I thought that when enabled it (the (M)SSP module) takes control over the I/O-pins - I'm obviously mistaken there.

    However, the PBP I2C commands are bitbanged, they don't use the I2C hardware in the PIC so there's no need to enable the hardware for it. It might lead to problems.

    /Henrik.

  2. #2
    Join Date
    Oct 2009
    Posts
    583


    Did you find this post helpful? Yes | No

    Default Re: 12F683 - basic code not working

    Thanks Henrik,

    So I can remove the SSPCON line ?

  3. #3
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,605


    Did you find this post helpful? Yes | No

    Default Re: 12F683 - basic code not working

    Yes, according to the datasheet the POR default of the SSPCON register is 0. Looking at the register definition it shows that as long as bit 5 is 0 the SSP module is disabled and its pins functions as normal I/O. This is probably also why it works the way you currently have it - you do have it configured for I2C mode but it's not actually enabled since bit 5 is cleared. Had you enabled it I don't think the I2C commands would've worked since the SSP module then would've been in control of the pins.

    /Henrik.

  4. #4
    Join Date
    Oct 2009
    Posts
    583


    Did you find this post helpful? Yes | No

    Default Re: 16F690 - code working - brain freeze on schematic !!!

    Guys,

    I've been resting my code using a DC motor driven by a simple transistor circuit as per attached which works well, with the intention of using a double pole change over relay to switch the polarity to the motor (throw off from my old model railway days as that's how we used to make the loco go backwards or forwards). The think is I can't get my head round how to use the transistor to turn the power on / off.

    I came up with the attached, but not sure if this would work, or if I should have the transistor between the relay and GND (ie C to relay, E to GND). I've left the Diode out as the motor is bi-directional

    Advice welcome before I blow up a handful of transistors trying
    Attached Images Attached Images   

  5. #5
    Join Date
    Sep 2009
    Posts
    755


    Did you find this post helpful? Yes | No

    Default Re: 16F690 - code working - brain freeze on schematic !!!

    I use this for motor driver:
    Name:  sch.png
Views: 1663
Size:  12.2 KB

  6. #6
    Join Date
    Oct 2009
    Posts
    583


    Did you find this post helpful? Yes | No

    Default Re: 16F690 - code working - brain freeze on schematic !!!

    Thanks you..

  7. #7
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,605


    Did you find this post helpful? Yes | No

    Default Re: 12F683 - basic code not working

    Hi,
    Regarding your first schematic, generally you need to put the transistor on the low side. Otherwise you need a higher voltage on the base than you've got on the collector. Put the relay "on top", then on to the motor and finally the transistor at the bottom, emitter to ground. Yes, the motor is biderectional but the current thru the transistor is always the same so put the diode back across is, cathode facing "up" of course.

    /Henrik.

Similar Threads

  1. 12F683 - Pin1 not working
    By ruijc in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 8th February 2014, 17:38
  2. 12F683 Maths and code genius reqd.
    By retepsnikrep in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 1st January 2014, 08:44
  3. please help with 12f683 pwm code
    By haidar in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 22nd May 2013, 21:25
  4. Problem converting 12F683 code to 12F1840
    By RossWaddell in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 14th March 2013, 01:55
  5. Working code but my layman approach uses too much code space
    By Christopher4187 in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 14th December 2012, 20:44

Members who have read this thread : 2

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts