Transistors issue for 8 bits uC - 16F876A.

Discussion in 'Embedded Systems and Microcontrollers' started by Art, Sep 5, 2015.

  1. Art

    Thread Starter Distinguished Member

    Sep 10, 2007
    785
    61
    Hi Guys :)
    This has to do with my core rope project. I’m pulling my hair out here :O

    I send a pulse through the pulse line, and try to read the transformer outputs
    from the secondaries into an eight bit mcu port. Only the first four bits are shown here.

    It is only bit 0 that is behaving itself, and bit 0 is working reliably.
    The input to the transistors from the former secondaries all look the same to me on a scope.
    This circuit should invert the signal, and usually be high, except when there’s a pulse.
    Bit zero does this, but all others are always zero volts (the highlighted connections) unless I pull the mcu out of the circuit.
    I would think that the ten turn windings on the toroids would normally be keeping the transistor bases low.
    The 5 Volt supply to all transistors is ok.

    Right now, this will read 0001, when it should be 0101 due to the pulse wire weave pattern shown here,
    but as I cycle through all address lines (only one shown here), the value of bit 0 is always correct.

    Any ideas of what I should try? Thanks :)

    [​IMG]
     
  2. ericgibbs

    AAC Fanatic!

    Jan 29, 2010
    2,503
    380
    hi,
    Are you sure the micro pins are set for Inputs and the internal pull ups are programmed Off.??
    E
     
  3. Art

    Thread Starter Distinguished Member

    Sep 10, 2007
    785
    61
    Hi, yes I have tried with and without pull-ups enabled, and portB is set to input.
    In fact the transistors can be forgotten. I removed the first two (bits 0 & 1),
    and connected the two micro inputs directly to their former secondaries.
    bit0 still works, it’s just no longer inverted, and bit1 still does not see anything.

    I can’t for the life of me figure out any hardware or software difference between
    one pin and the other seven.
     
  4. ericgibbs

    AAC Fanatic!

    Jan 29, 2010
    2,503
    380
    OK,
    Another possible problem, are you sure the pulse wire when passing thru the toroids is in the correct 'sense' as to induce a positive going pulse, relative to the transistor Base, in the toroid pickup coils.
     
    absf likes this.
  5. Art

    Thread Starter Distinguished Member

    Sep 10, 2007
    785
    61
    Yes, they are all the same phase. I get the pulse I want on their outputs until I connect something other than a scope.
    I tried swapping bit0 of the mcu to read bit7 of the rope, and it now reads bit7.
    So I’m going to guess I could read any former with portB.0.
    Yet I made them all digital and all inputs.. in fact I don’t think portB 16F876A can be analogue.
     
  6. ScottWang

    Moderator

    Aug 23, 2012
    4,854
    767
    The circuit you better using two stages of npn and pnp , so the output is low, because the uC accept the low in the beginning can be reducing the errors.
     
  7. takao21203

    Distinguished Member

    Apr 28, 2012
    3,577
    463
    I haven't seen your circuit memorizing anything they look like make-believe circuits to me.
     
    Art likes this.
  8. Art

    Thread Starter Distinguished Member

    Sep 10, 2007
    785
    61
    It turns out a silly mistake.
    I set the tris register for portb 0x01h instead of 0xFFh
    thinking it was a bit instead of byte, and now all is well.

    It’s easy to prove. If I dump the data over and over into a terminal continuously,
    and place a magnet over any of the ferrites, the bit associated with that ferrite
    becomes zero for all byte data associated with that channel because the magnet
    prevents coupling through that ferrite.
    I have screenshot your post and it features in the demo video I made today :)
    Usually when someone makes an ass of themselves on a forum,
    you don’t hear from them in the same thread again.

     
    Last edited: Sep 6, 2015
    absf likes this.
  9. ericgibbs

    AAC Fanatic!

    Jan 29, 2010
    2,503
    380
    Pleased to see that you have it working, nicely done.;)
    So it was the PORTB I/O
    E
     
  10. Art

    Thread Starter Distinguished Member

    Sep 10, 2007
    785
    61
    Lol yes I wasted a whole day messing with hardware over a line of software :D

     
  11. takao21203

    Distinguished Member

    Apr 28, 2012
    3,577
    463
    Where is the memory?
    Its just a delay line, a serial/parallel converter.

    Moreover its not clear to me what you want to proove or demonstrate with this circuit.

    For me a memory should really memorize something, if its a dynamic memory it needs refresh all the time.
     
  12. Art

    Thread Starter Distinguished Member

    Sep 10, 2007
    785
    61
    My last project on the same channel was RAM, and has been demonstrated as well.
    ROM is also memory or it wouldn't be called ROM.

    It converts parallel data (the rope memory) to serial.
    But before a micro was ever involved, the ROM board was still a memory.

    The first Rope ROM video on my channel clearly demonstrates with LEDs
    how two bytes can be retreived from a test board that only has two address lines.

    You understand this is the ROM used for Apollo guidance system right? ie. Not something I made up.
     
    Last edited: Sep 7, 2015
    absf and ericgibbs like this.
  13. jayanthd

    Member

    Jul 4, 2015
    274
    29
    Nice to hear that you got it working. You can add a capacitor from collector to GND of each transistor. If this expands the inverted pulse for a little more time then you can read many more such inputs.
     
  14. Art

    Thread Starter Distinguished Member

    Sep 10, 2007
    785
    61
    Thanks... I hear I'm supposed to learn about transistor biasing.
    After the first video on the topic I'm no more enlightened, but will try again :D

    I understand extending the pulse duration is beneficial but
    what do you mean then I can read many more such inputs?
     
  15. jayanthd

    Member

    Jul 4, 2015
    274
    29
    If you want to read 8 or 16 transistor collectors connected to MCU IO pins then you have to read fast before the logic states disappear. Capacitor will take time to discharge and so the inverted logic pulse will stay for a while when the transistors are ON. So, if the capacitors take 100 ms to discharge then you have sufficient time to read more inputs.
     
  16. Art

    Thread Starter Distinguished Member

    Sep 10, 2007
    785
    61
    Ok I get you there.
    The transistors themselves appear to be providing ample time, more than the raw pulses, though they aren't in the circuit presently.

    I am reading the port at once..
    8 bit at a time, not each bit in sequence.
    But there is still benefit in extending the pulse duration, i'll give them a go.
     
Loading...