가장 많이 본 글

이 블로그 검색

2018년 4월 27일 금요일

Serial port Monitoring and Commanding

Serial port Monitoring and Commanding

  PC에서 serial port를 이용해서 embedded system을 control 또는 debugging 하는 것은 개발자 들에게 꼭 필요한 일 입니다. 시중에 몇가지가 있지만 필요한 기능들이 많이 부족하고 그다지 마음에 들지도 않아서 Visual Basic을 이용해서 만들어 봤습니다.  주변에 사용하시는 분들의 조언을 받아 기능이 계속 Upgrade되고 있습니다. free하게 사용 하시면 됩니다. 하지만 error가 있을 수 있습니다. 양해해 주시기 바랍니다. 설치는 필요 없습니다.

  It is quite important for the engineers developing embedded system to control and debug its hardware and firmware. There are some good programs in the market but they are too complex or too simple for me, so I've made mine using Visual Basic. Functions are continuously upgraded referring to my colleagues' opinions. There is no copy right, so download and use freely. There might be errors, please understand. No installation is required.

Click here to download SerialCommander V4.6
Click here to download example command file

1. Features

  1) A group of commands can be transmitted and repeated with specified interval.
  2) List of Commands can be saved and read in.
  3) Work space also can be saved and retrieved automatically when starting.
  4) All pane colors and fonts can be reconfigured by user.
  5) User scratch pad is provided for memo and can be saved and recalled.
  6) Conversion functions for selected text are provided.
     ASCII -> HEX, Integer, Floating point,
     HEX -> ASCII, Integer, Floating point,
  7) Little or Big endian selection
  8) Separate hex monitoring window can be opened.
  9) Header and delimiter selection
  10) ASCII and binary hex mixed command can be transmitted by using '$' sign.
  11) A time stamp can be shown to help monitor an experiment.
  12) File dump and RX logging are provided.
  13) Search text pattern function
  14) All panes are resizable.
  15) Additional 40 more commands can be used.
  16) Multiple application can be opened and numbered.


2. Main Toolbar


File operation
1) Create a new command file
2) Open an existing command file
3) Save current commands in a file
** New command editor : enter new commands and save

1) Comm port select
2) Baudrate select
3) Comm port open|close
                                                     4) Comm port setup



1) Shows ASCII table
2) Invoke windows calulator
                  3) Custom hex converter/calculator


1) Change font and backcolors
2) Save current user workspace
                 3) About + brief usage




              1) TX/RX Transaction flashes ( Red for TX and Green for RX )
              2) Predefined command for abort and reset(format selectable using dropbox)

3. TX pane Toolbar


Clears current display of TX pane


Displays separate HEX monitoring window


Stamps current time in the TX pane


1) Changes current Font
2) Wordwrap On/Off
3) Find text

1) Change Endian : L represents Little, B for Big
2) Convert ASCII to HEX( Use dropdown to select mode
   ( Hex, integer 32 bit, float 32 bit )
                                        The conversion results will be shown in the conversion
                                              results pane.
                                        example : 12500 is selected, and the results

                                     3) Convert HEX to ASCII
                                         The results show each conversion
                                     4) Multiple conversion is allowed( 2 or more selection )



1) Opens file for dump ( Use dropdown to show contents )
2) Send file contents( Dump )

Saves selected text to a file


4. TX pane Statusbar


1) Display mode select : Use dropdown box to select display mode options
2) ASCII mode : Unprintable character option Null, CarriageReturn
3) HEX mode : Show address column - hex | decimal address
                                                   check selected again will make no address
                   Spacing on/off between bytes
                   Bytes/Line select ( 8 or 16 )
4) TXchrs : click to reset character counter
5) Selected : shows how many characters are selected.

5. RX pane Toolbar and Statusbar

  RX pane is identical to the tools in TX except for logging button.

Click to start to log data from RX. Specify file name at start. To stop logging, click this button again.

6. Conversion Results and User Scratch pad

Time stamp and file operations are provided.

7. Group command Column

1) Three group command are provided.
2) Select a group to be transmitted with radio buttons.
3) Specify command interval between each command.
4) Group command can be repeated with specified interval
   and checking Repeat check box.
5) HEX mode can be selected by checking HEX mode.
   HEX commands are like this "02 05 1f....03"
6) Select delimiter trimming( CR/LF )
7) Click send to start group command sequence







8. Immediate command Section


1) A header can be sent concatenated with any command and check or uncheck this function in accordance with your needs.
For example, this can be used for specifying address of RS485.
              2) Immediate Command List contains all possible command with comments.
                 Comments are identified with // or /*  */ or '  or -- to explain the usage.
                 Selected command in the combo box will be transferred to the Send Boxes
                 without its comment.

1) Three immediate command boxes are provided. They can be filled from Immediate Command List selection or be filled with direct typing in.
2) Send button transmits selected one.

1) Options are almost the same as Group commands.
2) Delimiters can be organized with trim and add selection radio buttons.
3) Repeat CMD send the selected with                                                                  specified interval.
               4) More command button(Green +) will provide additional 40 commands.


              5) Repeat command also can be applied.
                 Other options are applied as in the main window.

              6) Edit immediate command file button : all commands can be edited here
                 and can be saved. If you use group and more commands, do not save this
                 as the same file. This is for only the immediate file. Just close this window
                 and use file menu in the main tool bar in the case.


9. Main Statusbar


1) CommStatus indicates port status that is connected or disconnected
2) Command File shows currently opened file name. Click file name to show
   the last portion of a long file name.
3) RXchrs and TXchrs show the number of characters received and transmitted.
4) Selected shows the number of characters selected.

*** Please feedback when you find some errors or inconveniences.


2018년 4월 26일 목요일

PIC Peripheral Pin Select

PIC Peripheral Pin Select(PPS: 주변장치 Pin선택기능)

  PIC24 또는 32 Series 중에는 주변장치 pin을 program에서 select 할 수 있는 기능이 있는 chip들이 있습니다. HW design시 routing이 꼬이지 않도록 하거나 최단거리 배선을 할때 상당히 유용하게 사용할 수 있습니다. 하지만 어느 Pin이나 마음대로 선택, 지정 할 수 는 없고 일정범위 내에서 가능 합니다. 또한 I2C 같은 장치는 고정핀 으로 되어 있으므로 유의 해야 합니다.

  Some processors of PIC24 or PIC32 series has Peripheral Pin Select(PPS) feature and they are very useful when designing Hardware to make routing untwisted or shortest path. But they can not be selected or specified for any pins on the chip and have range of flexibility. Moreover, there are peripherals having fixed pins like I2C, so care must be taken to use this feature.

  다음은 정리한 PIC24FJ128 사용예 입니다. 다른 chip들도 이런 방식으로 정리하고 사용하면 매번 datasheet를 들춰보는 수고를 줄여도 됩니다.


  다음은 PIC32MX350 사용예 입니다.
Click here to download PPS selection example

2018년 4월 20일 금요일

PIC microprocessor selection

PIC microprocessor에 대한 경험을 알려 드리고 선택에 도움이 되었으면 합니다.


    저는 PIC을 접한지 꽤 되었는데 아직도 완벽 하다고는 생각지 않습니다. 너무나 종류도 많고 memory크기, interface도 다양해서 어떤것을 써야 될지 감이 오지 않을 정도 입니다. 하지만 engineer들은 어떻게 해서든지 일을 끝내야 하기 때문에 선택을 해야만 하는 입장 입니다. 
    이제는 경쟁사도 많고 가격도 많이 평준화 되어 대량생산용이 Application이 아니면 가격에 크게 구애받지 않고 spec이 좋은 것을 선택하여 일을 멋지게 끝내는 것도 방법중 하나 일 겁니다. 
    기존 series에 계속해서 upgrade가 되어서 나오는 중이라 저도 어떤것이 좋다고 말씀 드리기 어렵습니다. 뭔가 사용해 보고 익숙해 지면 잘 바꾸지 않는 것이 Engineer들의 특성인 지라 더욱 그렇습니다.

계열 별로 제가 사용해본 경험으로는,

  1. 16F 계열은 싼가격이 장점 이지만 ROM/RAM size가 작아서 기능이 많지 않은 Job에나 적당 할거 같습니다. clock  speed도 높지 않습니다.
  2. 18F 계열은 8bit processor 입니다. 중급 정도 Application에 사용하면 좋습니다. 하지만 ROM/RAM size는 부족한 감이 있습니다. clock speed는 대략 40MHz 정도로 보면 됩니다. RAM은 4K 정도 입니다.
  3. 24FJ 계열은 16bit 입니다. 중 ~ 고급 정도에 적합할거 같습니다. 하지만 RAM size가 32K barrier가 있습니다. 64K를 넘는 종류도 있습니다만 32K를 넘는 부분을 access 하려면 좀 특수한 조작을 해야하는 불편함이 있었습니다. clock은 18F와 거의 비슷한 수준 입니다.  따라서 처리속도 면에서는 18F 보다 훨씬 낫다고 얘기하긴 어려울듯 합니다. Peripheral Pin Select(PPS, 주변장치 Pin mapping)가 지원되는 chip들이 있습니다.
  4. dsPIC 계열은 많이 사용해 보지 않았습니다만 Core는 24F 계열을 기반으로 고속 Clock탑재, control 및 signal processing을 위한 다양한 module들을 용도에 따라 선택 할 수 있습니다.
  5. 32MX 계열은 32bit processor 입니다. ROM/RAM size가 크고 Linear하게 acess 됩니다. Clock speed는 100MHz 정도로 보면 됩니다. Clock에 걸맞게 명령 실행시간 또한 빠릅니다. 풍부한 interface module들이 있습니다. 아마 ARM processor등을 겨냥하여 나온것 같습니다. 사용 하기가 까다롭지 않습니다. 가격이 많이 내려가서 저는 웬만한 application에는 32MX를 사용합니다.

 저는 아래와 같이 Selection table을 만들어서 필요할 때 사용하고 있습니다.


* PU/PD/OD 는 각각 Pullup, Pulldown 및 OpenDrain 입니다.
*  IO bit change time은 port에 0과 1을 교대로 써줄때 측정한 값 입니다.

 Operation time은 evaluation시에 oscilloscope로 실측한 값 입니다. 주변장치 혹은 Host와 통신 시에는 data의 formatting이 필요한 경우가 많아서 그에 대한 speed또한 측정해 보았습니다. 부동소수점 으로 갈 수록 32bit가 위력을 발휘 하는거 같습니다. 앞으로 설명드릴 내용은 주로 PIC32MX350을 위주로 전개해 나갈 것 입니다.


Click here to download Selection Guide


XIDE Settings

XIDE user settings

  XIDE를 Install 후에는 약간의 사용자 setting으로 더욱 유용하게 사용할 수 있습니다.  Editor setting이 내용이 많습니다. Setting이 끝난 후에는 export하여 저장이 가능하고 나중에 새로운version을 설치시 import하여 setting 내용을 유지 할 수 있습니다.

  After installing XIDE, some user setting make it more useful especially for editor. User settings can be exported and can be used when installing newer version by importing the setting contents.

  Tools>Option을 선택 하면 Option 화면이 나타 납니다.


  Click Editor icon, then click formatting tab.


  Select Language as C, then modify settings. Your modification will be shown in the preview pane. Then click Code Templates.


  일종의 단축키 입니다. code작성시 단축형을 입력하고 tab key를 치면 expanded text가 나타 납니다. 아주 유용 합니다. 주로 block형 으로 된 if, for, switch, function등을 자신에게 맞도록 변경하고 사용하면 됩니다. List에 없는 것은 new를 click하고 만들면 됩니다. 이제 Fonts & Colors icon을 click하고 font를 선택 합니다.

  The code templates are sort of shortcut keys. When writing codes enter the abbreviation then press tab key, then the expanded text will appear. It's very useful to build a code structure. Modify some block of codes like - if, for, switch and function - to fit to your needs. If anything needed not in the list, click new button and make your own. Now click Fonts & Colors icon and then select font. 


  Click Team icon and then select Action Items tab.


  ToDo patterns는 Code 에 comment로 삽입해 놓으면 나중에 이를 근거로 해당 부분을 찾을 수 있습니다. ( Window>Action items )

  ToDo patterns can be inserted in the source code as a comment and they could be found with Window>Action items. It reminds what to do at that point.

Click Appearance icon and select look and feel. In my case I selected Nimbus.


  마지막 으로 좌측하단의 Export를 Click 하고 Option에서 all을 check, target zip file을 결정후 OK를 누르면 일반적인 setting이 대강 끝납니다.


  Finally, press export button in the bottom left corner, then the export dialog box will appear. Check All in the options and specify target zip file name and press OK button. 










2018년 4월 18일 수요일

XIDE and XC compiers Installation

1. XIDE Installation

  XIDE는 Microchip에서 download 합니다. 순서는 XIDE를 설치후 필요한 compiler를 download 하고 compiler를 설치 하면 됩니다. XIDE와 compiler는 여러개의 version을 설치하고 선택이 가능 합니다. 다음의 Link로 가서 download 합니다.

 XIDE can be downloaded from Microchip homepage. The order of the installation is : firstly download XIDE and then compiler. Multiple installation by version is allowed and the specified one can be selected and used. Use the following links.

 XIDE download for the latest
 XIDE download for the older ones


  Downloads tab을 Click 하고 자신의 OS에 맞는 것을 선택하고 download 합니다. 설치는 매우 간단하여 동의 할 것은 동의하고 모두 yes로 하면 됩니다.

  Click Download tab and then select the one matched with your OS. Installation is that simple with "accept and yes to all" basis.

2. XC compiler Installation

  XIDE 설치후 다음의 link에서 개발에 필요한 compiler들을 download받아 설치 합니다.

  After installing XIDE, download compilers you need from the following links and install them.

  XC8   -- For 16, 18 series
  XC16 -- For 24, dsPIC series
  XC32 -- For 32 series

  XC compilers download for the latest
  XC compilers download for the older ones


                                            For the latest

                                            For the older ones

  Download tab을 Click하고 필요한 compiler들을 download 받아 설치 합니다.

  Click Download tab and then select the one matched with your OS. Installation is that simple with "accept and yes to all" basis.






2018년 4월 17일 화요일

PIC Development Environment(개발환경)

Development environment is more important than others. This is the stepping stone for success.
개발환경 구축이 무엇보다 중요 합니다. 첫단추를 잘 끼워야 하니까요.

 개발에는 source file을 만들 Editor, source를 기계어로 변환해줄 Compiler 및 target에 Download하고 test할 debugger등이 필수적 으로 필요하게 됩니다. 수년전 까지만 해도 변변한 IDE(Integrated Development Environment:통합개발환경)이 없어서 editor는 A사, compiler는 B사, debugger는 C사 등의 제품을 나누어 쓰느라 과정도 복잡 지루하고 관리가 특히 어려웠습니다.

 1. XIDE
  Microchip사 에서는 수년전 XIDE라는 통합개발환경을 무료로 제공하고 있습니다. 이전에는 MPLAB이라는 IDE를 제공 했었습니다만 editor기능이 약하고 여러가지 기능이 좀 떨어졌던 기억이 있습니다. XIDE는 netBeans를 기반으로 만들어져 강력한 editing기능 및 개발에 필요로 하는 detail까지 잘 갖춰져 있는것 같습니다.
  Editing -> Compiling -> Downloading -> Debugging까지 일련의 과정이 XIDE에서 수행할 수 있습니다.
  1년에 2 ~ 3회 새로운 version이 발표되곤 합니다.

 2. Complier
  Microchip에서 제공하는 XCxx를 사용 하면 됩니다. 또는 CCSC라는 pic compiler를 사용해도 됩니다. 하지만 CCSC에는 좀 뭔가 확실히 꼬집어 내기 어려운 bug가 있는거 같습니다. 같은 source라도 compiling후에 download하고 보면 어떤때는 되고 어떤때는 안되고 하는 일이 저 뿐만 아니라 여러분이 경험한 사실 입니다. 또한 version이 바뀔때 마다 이전 version과 약간씩 instruction을 바꿔야 하는... 뭐 이런 여러가지로 인해 저는 사용하지 않고 있습니다. 치명적인 것은 32bit processor가 지원되지 않는다는 것입니다.
  XC compiler는 예전 Hitec compiler에 기반을 두고 만든 것 입니다. processor의 bit수에 따라 XC8, XC16 and XC32로 되어 있습니다. 무료로 제공되는 것과 유료로 구입해야 하는 제품이 있습니다. 차이점은 optimization level(최적화)인데요, 좀 memory가 큰 processor를  선택하면 무료 version이라도 큰 차이없이 사용가능 합니다.
  Update는 processor family가 추가 될 때마다 새로운 version을 제공하는것 같습니다. XC32 경우엔 자사의 harmony라는 platform과 연계해서 사용하도록 변경이 많이 이루어 지고 있습니다. 마치 microsoft의 .NET과 같이 사용하도록 한거 같은데 저 같은 소, 중규모의 project에는 적용 하기에 버거운 면이 많더군요. 더구나 예전에 사용하던 peripheral library가 적용이 안되서 아주 곤란한 문제가 많습니다. 그래서 저는 V1.34를 사용 합니다.

3. Debugger
  Download 및 debugging이 가능한 tool은 많은 종류가 있습니다. 완벽한 debugging을 하려면 ICD, ICE등을 사용하면 좋은데 가격이 만만치 않습니다. 따라서 간편하게 사용할 목적으로 pickit2나 pickit3를 사용하면 좋습니다. China영향으로 그나마 가격이 많이 down되었습니다. 이전엔 pickit2를 많이 사용했는데 지원되지 않는 device가 늘어나게 되어 pickit3를 사용 하는게 좋습니다. 가격은 1~2만원 정도 입니다. 간단한 debug는 가능 하지만 너무 많은것을 원하기는 어렵습니다. 최근에는 pickit4가 출시되어 사용해 보았는데 pickit3와는 확연히 차이 납니다. 가격을 7만원 정도 입니다. XIDE와 함께 제공되는 IPE를 사용하면 별도로 download 할 수 있습니다.