Menu

How do I add new components in simulide program?

2016-02-27
2019-07-09
1 2 > >> (Page 1 of 2)
  • José Fernando Moraes

    I would like to add new components in simulide, it is possible, how it's done. Is there a tutorial?

     
  • Santiago

    Santiago - 2016-02-27

    There is a way to create components as subcircuits, using elements that already exist in simulide.
    This way you don't have to compile, but you cannot create really new components.

    It's possible to create new components if you have some C++, Qt and compiling skills.
    If this is the case let me know and i will guide you.

     
  • José Fernando Moraes

    One of the components that would like to see in simulide is the lcd display 16 columns and 1 row

     
  • José Fernando Moraes

    I found this stuff done in C ++ on the creation of the module PCD8544

    //
    // C++ Implementation: pcd8544
    //
    // Description: This component emulates a graphic LCD module based on the
    // PCD8544 controller.
    //
    // Author: Roland Elek elek.roland@gmail.com, (C) 2010
    //
    // Copyright: See COPYING file that comes with this distribution
    //
    //

    include "libraryitem.h"

    include "pcd8544.h"

    include "ecnode.h"

    include <qstring.h>

    include <klocale.h>

    include <qimage.h>

    include <qfont.h>

    include <stdio.h>

    Pcd8544::Pcd8544( ICNDocument icnDocument, bool newItem, const char id )
    : Component( icnDocument, newItem, id ? id : "pcd8544" )
    {

    m_name = i18n("PCD8544 LCD");
    setSize( -50, -50, 100, 100 );
    
    m_pCs = 0;
    m_pRst = 0;
    m_pScl = 0;
    m_pSi = 0;
    m_pDc = 0;
    //We don't initialize m_aDispRam - the real display doesn't either
    m_pdisplayImg = new QImage(84,48,1,2,QImage::LittleEndian);
    m_pdisplayImg->setColor(1,qRgb(0,0,0));
    m_pdisplayImg->setColor(0,qRgb(200,255,150));
    clearLcd();
    
    initPins();
    

    }

    Pcd8544::~Pcd8544()
    {
    }

    Item * Pcd8544::construct(ItemDocument itemDocument, bool newItem, const char id) {
    return new Pcd8544( (ICNDocument*)itemDocument, newItem, id );
    }

    LibraryItem * Pcd8544::libraryItem() {
    return new LibraryItem(
    "ec/pcd8544",
    i18n("PCD8544 LCD"),
    i18n("Outputs"),
    "lcd.png",
    LibraryItem::lit_component,
    Pcd8544::construct
    );
    }

    void Pcd8544::initPins() {
    createPin(-40,56,270,QString("dc"));
    createPin(-23,56,270,QString("rst"));
    createPin(-6,56,270,QString("cs"));
    createPin(11,56,270,QString("scl"));
    createPin(28,56,270,QString("si"));

    ECNode *node;
    
    if(! m_pDc) {
        node = ecNodeWithID("dc");
        m_pDc = createLogicIn(node);
        m_pDc->setCallback(this, (CallbackPtr)&Pcd8544::inStateChanged);
    }
    if(! m_pRst) {
        node = ecNodeWithID("rst");
        m_pRst = createLogicIn(node);
        m_pRst->setCallback(this, (CallbackPtr)&Pcd8544::inStateChanged);
    }
    if(! m_pCs) {
        node = ecNodeWithID("cs");
        m_pCs = createLogicIn(node);
        m_pCs->setCallback(this, (CallbackPtr)&Pcd8544::inStateChanged);
    }
    if(! m_pScl) {
        node = ecNodeWithID("scl");
        m_pScl = createLogicIn(node);
        m_pScl->setCallback(this, (CallbackPtr)&Pcd8544::inStateChanged);
    }
    if(! m_pSi) {
        node = ecNodeWithID("si");
        m_pSi = createLogicIn(node);
        m_pSi->setCallback(this, (CallbackPtr)&Pcd8544::inStateChanged);
    }
    

    }

    void Pcd8544::inStateChanged( bool newState ) {
    Q_UNUSED(newState);

    if(!m_pRst->isHigh()) {
        reset();
        return;
    }
    
    if(!m_pCs->isHigh()) {
        static bool clkH = m_pScl->isHigh();
        if(!clkH && m_pScl->isHigh()) {
            //SCL rising edge
            m_cinBuf &= ~1; //Clear bit 0
            if(m_pSi->isHigh()) m_cinBuf |= 1;
            if(m_ibit == 7) {
                if(m_pDc->isHigh()){
                    //(Write data)
                    m_aDispRam[m_iY][m_iX] = m_cinBuf;
                    incrementPointer();
                    updateLcd();
                } else {
                    if(m_cinBuf == 0) {
                        //(NOP)
                    } else if((m_cinBuf & 0xF8) == 0x20) {
                        //(Function set)
                        m_bH = ((m_cinBuf & 0x01) == 1);
                        //TODO: Addressing mode currently ignored,
                        //always using horizontal mode.
                        setPd(((m_cinBuf & 0x04) == 0x04) ? 1 : 0);
                    }
                    if(m_bH) {
                        //(Extended instruction set)
                        //None implemented yet - are they relevant at all?
                        //Visualization of e.g. contrast setting could be
                        //useful in some cases, meaningless in others.
                    } else {
                        //(Basic instruction set)
                        if((m_cinBuf & 0xFA) == 0x08) {
                            //(Display control)
                            setDispCtl(((m_cinBuf & 0x04) == 0x04) ? 1 : 0,
                                    m_cinBuf & 0x01);
                        } else if((m_cinBuf & 0xF8) == 0x40) {
                            //(set Y address of RAM)
                            m_iY = m_cinBuf & 0x07;
                        } else if((m_cinBuf & 0x80) == 0x80) {
                            //(set X address of RAM)
                            m_iX = m_cinBuf & 0x7F;
                        } 
                    }
                }
                m_ibit = 0;
            } else {
                m_cinBuf <<= 1;
                m_ibit++;
            }
        }   
    }
    

    }

    void Pcd8544::dataChanged() {
    //No data. Could be display resolution - the PCD8544
    //chip supports anything up to 84x48. Plus, there is
    //at least one chip with a PCD8544 compatible instruction
    //set that supports larger LCD panels.
    }

    void Pcd8544::drawShape(QPainter &p) {
    initPainter(p);

    p.drawRect((int)x()-50,(int)y()-50,100,100);
    p.drawImage((int)x()-41,(int)y()-40,*m_pdisplayImg);
    p.setFont(QFont("sans",6));
    p.drawText((int)x()-48,(int)y()+40,QString("D/C /RST /CS SCL SI")); //TODO: beautify this
    p.setFont(QFont());
    p.drawText((int)x()-30,(int)y()-55,"PCD8544");
    
    deinitPainter(p);
    

    }

    void Pcd8544::updateLcd() {
    if(m_bPD || (!(m_bD || m_bE))) {
    //We are in power-down or blank display mode,
    //blank the visuals
    m_pdisplayImg->fill(0);
    return;
    }
    if((!m_bD) && m_bE) {
    //All segments on
    m_pdisplayImg->fill(1);
    return;
    }

    for(int row=0;row<6;row++) {
        for(int col=0;col<84;col++) {
            char abyte = m_aDispRam[row][col];
            for(int bit=0;bit<8;bit++) {
                //This takes inverse video mode into account:
                m_pdisplayImg->setPixel(col,row*8+bit,
                    (abyte & 1) ^ ((m_bD && m_bE) ? 1 : 0));
    
                abyte >>= 1;
            }
        }
    }
    

    }

    void Pcd8544::clearLcd() {
    m_pdisplayImg->fill(0);
    }

    void Pcd8544::incrementPointer() {
    //TODO: Vertical addressing
    m_iX++;
    if(m_iX >= 84) {
    m_iX = 0;
    m_iY++;
    }
    if(m_iY >= 6) {
    m_iY = 0;
    }
    }

    void Pcd8544::reset() {
    m_ibit = 0;
    m_bPD = true;
    m_bV = m_bH = false;
    m_bE = m_bD = false;
    m_iX = m_iY = 0;
    updateLcd();
    }

    void Pcd8544::setPd(bool pd) {
    m_bPD = pd;
    updateLcd();
    }

    void Pcd8544::setDispCtl(bool D, bool E) {
    m_bD = D;
    m_bE = E;
    updateLcd();
    }

     
  • Santiago

    Santiago - 2016-02-28

    One of the components that would like to see in simulide is the lcd display 16 columns and 1 row

    I'm working in the HD44780 LCD 16x2 and 20x4, it's half-done, it will be in next release.
    If you want i can add 16x1, but i think it's not very used.

    I found this stuff done in C ++ on the creation of the module PCD8544

    Yes... i already adapted that code from ktechlab project to work in simulide.
    You can see it in the video example.

    HD44780 is a bit more complex.

    Thanks for the interest.

     
  • José Fernando Moraes

    You have 16x1 LCD display library? Can you send to me? If yes, you teach me to add?

     
    • Santiago

      Santiago - 2016-02-28

      No.. im working in 16x2 and 20x4, but still need some time.
      When that is done it will be easy to add a 16x1.

      By now there is not a library system for simulide components, you have to
      compile the whole program.

       

      Last edit: Santiago 2016-02-28
  • José Fernando Moraes

    Ok .
    It would be nice to also see transistors, mosfet, diode, electrolytic capacitor, who knows ...

     
  • Santiago

    Santiago - 2016-02-28

    There is already diode.
    Transistor and Mosfet are planned for next release.

    It's good to know which components the people would like to have in next release. by now i'm working in lcd and steeper motor, the plans for next release are:

    - Lcd
    - Led Bar
    - Led Matrix
    - Transistor
    - Mosfet
    - Volt. Regulator
    - Conmute Switch
    - Steeper & maybe other motors( servo, dc )
    

    And maybe some other.

     
  • Anonymous

    Anonymous - 2016-03-28

    Hi,

    Standard anrduino external components like retractors, sensors etc.

     
  • Santiago

    Santiago - 2016-03-28

    Hi anonymous.

    Could you be more concrete?
    Wich ones would you like to see in SimulIDE? by preference.

     
  • José Fernando Moraes

    Hi Santiago, has idea for the new version?

     
  • Anonymous

    Anonymous - 2016-07-07

    Great Project. Thanks for the work. I like the idea of some sensors and motors. I was wondering if there are any plans to support EEPROMs or Flash devices?

    Thanks again and keep up the great work.

    Kevin

     
  • hovercrfat-sf

    hovercrfat-sf - 2016-07-09

    Hi Santiago.
    I have writen a plugin for older-but-smaller brother of SimulIDE - simutron project.
    I choosed it because it is more simple and stable just for now,
    and also it supports creation of plugins in the form of separate shared libraries.
    Plugin implements near the same functionality as the AVR processor component in the SimulIDE:
    - load firmware
    - reset processor
    - start/stop GDB host
    - connect serial terminal or other controlling software from the host system via pty
    - run firmware near realtime
    - store the firmware settings in project file and restore it on project load

    I understand that SimulIDE supersede the simutron project,
    but nevertheless I want to ask your to give me a write access into
    simutron repository, because I believe this project still can be usefull
    for someone in conjunction with my AVR plugin.
    Can you please?
    After some time I can then switch to SimulIDE and help you there, if would you agree.
    Can send you copy of my simutron project. source tree for evaluation.

     
  • Santiago

    Santiago - 2016-07-10

    Hi hovercraft-sf.

    Glad you are working with simutron.
    Just comment that simutron is an only digital simulator. Also the plugin system doesn´t work in windows, thats why i discontinued it.Any idea about component plugins for simulide would be very apreciated.
    I added you to simutron project, so now you have access, feel free to work in the project however you want.

    Regards.

     
    • hovercrfat-sf

      hovercrfat-sf - 2016-07-12

      Santiago - thank you very much for grant. I will commit my add-ons to simutron in a couple of days. Also some (minor) changes to its core neaded.

       
  • Santiago

    Santiago - 2016-07-10

    About next release and new components.
    I have little chances to work on simulide, any help will be very apreciated.
    By now i have HD44780 lcd and steeper motor working.
    Also solved some problems with arduino pwm and some other bugs.

    I´m thinking in doing a release this mounth with this changes

     

    Last edit: Santiago 2016-07-10
  • Anonymous

    Anonymous - 2016-09-26

    Hola Santiago, este pastebin contiene el backtrace de SimulIde para Linux de 64bits, falla cuando se carga el archivo.hex de un microcontrolador PIC.

    Saludos y buen software
    http://pastebin.com/0gsfF1e1

     
  • Anonymous

    Anonymous - 2017-02-26

    Hola Santiago, what are the chances to add more logic chips, like shift registers, 555 timer, decade counter/divider, flip flops and others, thanks, Deo is my name

     
  • Santiago

    Santiago - 2017-02-26

    Que tal Deo...
    You can do subcircuits containing logic gates, shift registers and latches just creating the proper descriptor files, 74hc in logic section of components are an example, have a look in data/subcircuits.xml and data/logic/file.subcircuit and data/logic/file.package to have an idea.
    Basically you have to write a package file with size, pins and so. And a subcircuit file, with components like gates and conections betwen then and to pins.
    If you need help with this method just tell me.

    For 555 and other complex chips they should be programed. Give a list of your interest and i'll will add some if possible.
    If you know about C++ programing we could do much more...

     
  • Anonymous

    Anonymous - 2017-04-13

    hii...i am beginner, i want to know about how to add new component in simulide in linux.

     
  • Santiago

    Santiago - 2017-04-13

    Hi Aonymous.
    I will add a page to the wiki about creating subcircuits in next days.
    Stay tuned.

     
  • Santiago

    Santiago - 2017-04-15

    I Added a minmal tutorial about creating subcircuit type components:
    https://sourceforge.net/p/simulide/wiki/subcircuits/

    When i have more time i will explain a bit more, but as an start point is enought.

     
    👍
    1
  • Anonymous

    Anonymous - 2017-08-26

    I need to simulate a standard PS/2 PC keyboard for my PIC project! So please help me out!

     
1 2 > >> (Page 1 of 2)
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.